\n ';
contentReady(el.dialog);
// Set attributes
_setAttributes(el.dialog, options);
// Prompt events
if (options.isPrompt && options.submitOnEnter) {
el.input = el.dialog.querySelector('.text-input');
el.input.onkeypress = function (event) {
if (event.keyCode === 13) {
el.dialog.hide().then(function () {
if (el) {
var resolveValue = el.input.value;
_destroyDialog();
options.callback(resolveValue);
resolve(resolveValue);
}
});
}
};
}
// Button events
el.footer = el.dialog.querySelector('.alert-dialog-footer');
util$1.arrayFrom(el.dialog.querySelectorAll('.alert-dialog-button')).forEach(function (buttonElement, index) {
buttonElement.onclick = function () {
el.dialog.hide().then(function () {
if (el) {
var resolveValue = index;
if (options.isPrompt) {
resolveValue = index === options.primaryButtonIndex ? el.input.value : null;
}
el.dialog.remove();
_destroyDialog();
options.callback(resolveValue);
resolve(resolveValue);
}
});
};
el.footer.appendChild(buttonElement);
});
// Cancel events
if (options.cancelable) {
el.dialog.cancelable = true;
el.dialog.onDialogCancel = function () {
setImmediate(function () {
el.dialog.remove();
_destroyDialog();
});
var resolveValue = options.isPrompt ? null : -1;
options.callback(resolveValue);
resolve(resolveValue);
};
el.dialog.addEventListener('dialog-cancel', el.dialog.onDialogCancel, false);
}
// Show dialog
document.body.appendChild(el.dialog);
options.compile(el.dialog);
setImmediate(function () {
el.dialog.show().then(function () {
if (el.input && options.isPrompt && options.autofocus) {
var strLength = el.input.value.length;
el.input.focus();
el.input.setSelectionRange(strLength, strLength);
}
});
});
});
};
/**
* @method alert
* @signature alert(message [, options] | options)
* @return {Promise}
* [en]Will resolve to the index of the button that was pressed or `-1` when canceled.[/en]
* [ja][/ja]
* @param {String} message
* [en]Notification message. This argument is optional but if it's not defined either `options.message` or `options.messageHTML` must be defined instead.[/en]
* [ja][/ja]
* @param {Object} options
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクトです。[/ja]
* @param {String} [options.message]
* [en]Notification message.[/en]
* [ja]アラートダイアログに表示する文字列を指定します。[/ja]
* @param {String} [options.messageHTML]
* [en]Notification message in HTML.[/en]
* [ja]アラートダイアログに表示するHTMLを指定します。[/ja]
* @param {String | Array} [options.buttonLabels]
* [en]Labels for the buttons. Default is `"OK"`.[/en]
* [ja]確認ボタンのラベルを指定します。"OK"がデフォルトです。[/ja]
* @param {Number} [options.primaryButtonIndex]
* [en]Index of primary button. Default is the last one.[/en]
* [ja]プライマリボタンのインデックスを指定します。デフォルトは 0 です。[/ja]
* @param {Boolean} [options.cancelable]
* [en]Whether the dialog is cancelable or not. Default is `false`. If the dialog is cancelable it can be closed by clicking the background or pressing the Android back button.[/en]
* [ja]ダイアログがキャンセル可能かどうかを指定します。[/ja]
* @param {String} [options.animation]
* [en]Animation name. Available animations are `none` and `fade`. Default is `fade`.[/en]
* [ja]アラートダイアログを表示する際のアニメーション名を指定します。"none", "fade"のいずれかを指定できます。[/ja]
* @param {String} [options.id]
* [en]The `` element's ID.[/en]
* [ja]ons-alert-dialog要素のID。[/ja]
* @param {String} [options.class]
* [en]The `` element's class.[/en]
* [ja]ons-alert-dialog要素のclass。[/ja]
* @param {String} [options.title]
* [en]Dialog title. Default is `"Alert"`.[/en]
* [ja]アラートダイアログの上部に表示するタイトルを指定します。"Alert"がデフォルトです。[/ja]
* @param {String} [options.modifier]
* [en]Modifier for the dialog.[/en]
* [ja]アラートダイアログのmodifier属性の値を指定します。[/ja]
* @param {String} [options.maskColor]
* [en]Color of the background mask. Default is "rgba(0, 0, 0, 0.2)" ("rgba(0, 0, 0, 0.3)" for Material).[/en]
* [ja]背景のマスクの色を指定します。"rgba(0, 0, 0, 0.2)"がデフォルト値です。[/ja]
* @param {Function} [options.callback]
* [en]Function that executes after dialog has been closed.[/en]
* [ja]アラートダイアログが閉じられた時に呼び出される関数オブジェクトを指定します。[/ja]
* @description
* [en]
* Display an alert dialog to show the user a message.
*
* The content of the message can be either simple text or HTML.
*
* It can be called in the following ways:
*
* ```
* ons.notification.alert(message, options);
* ons.notification.alert(options);
* ```
*
* Must specify either `message` or `messageHTML`.
* [/en]
* [ja]
* ユーザーへメッセージを見せるためのアラートダイアログを表示します。
* 表示するメッセージは、テキストかもしくはHTMLを指定できます。
* このメソッドの引数には、options.messageもしくはoptions.messageHTMLのどちらかを必ず指定する必要があります。
* [/ja]
*/
notification.alert = function (message, options) {
return notification._createAlertDialog(message, options, {
buttonLabels: ['OK'],
title: 'Alert'
});
};
/**
* @method confirm
* @signature confirm(message [, options] | options)
* @return {Promise}
* [en]Will resolve to the index of the button that was pressed or `-1` when canceled.[/en]
* [ja][/ja]
* @param {String} message
* [en]Notification message. This argument is optional but if it's not defined either `options.message` or `options.messageHTML` must be defined instead.[/en]
* [ja][/ja]
* @param {Object} options
* [en]Parameter object.[/en]
* @param {Array} [options.buttonLabels]
* [en]Labels for the buttons. Default is `["Cancel", "OK"]`.[/en]
* [ja]ボタンのラベルの配列を指定します。["Cancel", "OK"]がデフォルトです。[/ja]
* @param {Number} [options.primaryButtonIndex]
* [en]Index of primary button. Default is the last one.[/en]
* [ja]プライマリボタンのインデックスを指定します。デフォルトは 1 です。[/ja]
* @description
* [en]
* Display a dialog to ask the user for confirmation. Extends `alert()` parameters.
* The default button labels are `"Cancel"` and `"OK"` but they can be customized.
*
* It can be called in the following ways:
*
* ```
* ons.notification.confirm(message, options);
* ons.notification.confirm(options);
* ```
*
* Must specify either `message` or `messageHTML`.
* [/en]
* [ja]
* ユーザに確認を促すダイアログを表示します。
* デオルとのボタンラベルは、"Cancel"と"OK"ですが、これはこのメソッドの引数でカスタマイズできます。
* このメソッドの引数には、options.messageもしくはoptions.messageHTMLのどちらかを必ず指定する必要があります。
* [/ja]
*/
notification.confirm = function (message, options) {
return notification._createAlertDialog(message, options, {
buttonLabels: ['Cancel', 'OK'],
title: 'Confirm'
});
};
/**
* @method prompt
* @signature prompt(message [, options] | options)
* @param {String} message
* [en]Notification message. This argument is optional but if it's not defined either `options.message` or `options.messageHTML` must be defined instead.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Will resolve to the input value when the dialog is closed or `null` when canceled.[/en]
* [ja][/ja]
* @param {Object} options
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクトです。[/ja]
* @param {String | Array} [options.buttonLabels]
* [en]Labels for the buttons. Default is `"OK"`.[/en]
* [ja]確認ボタンのラベルを指定します。"OK"がデフォルトです。[/ja]
* @param {Number} [options.primaryButtonIndex]
* [en]Index of primary button. Default is the last one.[/en]
* [ja]プライマリボタンのインデックスを指定します。デフォルトは 0 です。[/ja]
* @param {String} [options.placeholder]
* [en]Placeholder for the text input.[/en]
* [ja]テキスト欄のプレースホルダに表示するテキストを指定します。[/ja]
* @param {String} [options.defaultValue]
* [en]Default value for the text input.[/en]
* [ja]テキスト欄のデフォルトの値を指定します。[/ja]
* @param {String} [options.inputType]
* [en]Type of the input element (`password`, `date`...). Default is `text`.[/en]
* [ja][/ja]
* @param {Boolean} [options.autofocus]
* [en]Autofocus the input element. Default is `true`. In Cordova, `KeyboardDisplayRequiresUserAction` in `config.xml` must be `false` to activate this feature.[/en]
* [ja]input要素に自動的にフォーカスするかどうかを指定します。デフォルトはtrueです。Cordova環境では、この機能を有効にするためには `config.xml` で `KeyboardDisplayRequiresUserAction` を `false` に設定する必要があります。[/ja]
* @param {Boolean} [options.submitOnEnter]
* [en]Submit automatically when enter is pressed. Default is `true`.[/en]
* [ja]Enterが押された際にそのformをsubmitするかどうかを指定します。デフォルトはtrueです。[/ja]
* @description
* [en]
* Display a dialog with a prompt to ask the user a question. Extends `alert()` parameters.
*
* It can be called in the following ways:
*
* ```
* ons.notification.prompt(message, options);
* ons.notification.prompt(options);
* ```
*
* Must specify either `message` or `messageHTML`.
* [/en]
* [ja]
* ユーザーに入力を促すダイアログを表示します。
* このメソッドの引数には、options.messageもしくはoptions.messageHTMLのどちらかを必ず指定する必要があります。
* [/ja]
*/
notification.prompt = function (message, options) {
return notification._createAlertDialog(message, options, {
buttonLabels: ['OK'],
title: 'Alert',
isPrompt: true,
autofocus: true,
submitOnEnter: true
});
};
/**
* @method toast
* @signature toast(message [, options] | options)
* @return {Promise}
* [en]Will resolve when the toast is hidden.[/en]
* [ja][/ja]
* @param {String} message
* [en]Toast message. This argument is optional but if it's not defined then `options.message` must be defined instead.[/en]
* [ja][/ja]
* @param {Object} options
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクトです。[/ja]
* @param {String} [options.message]
* [en]Notification message.[/en]
* [ja]トーストに表示する文字列を指定します。[/ja]
* @param {String} [options.buttonLabel]
* [en]Label for the button.[/en]
* [ja]確認ボタンのラベルを指定します。[/ja]
* @param {String} [options.animation]
* [en]Animation name. Available animations are `none`, `fade`, `ascend`, `lift` and `fall`. Default is `ascend` for Android and `lift` for iOS.[/en]
* [ja]トーストを表示する際のアニメーション名を指定します。"none", "fade", "ascend", "lift", "fall"のいずれかを指定できます。[/ja]
* @param {Number} [options.timeout]
* [en]Number of miliseconds where the toast is visible before hiding automatically.[/en]
* [ja][/ja]
* @param {Boolean} [options.force]
* [en]If `true`, the toast skips the notification queue and is shown immediately. Defaults to `false`.[/en]
* [ja][/ja]
* @param {String} [options.id]
* [en]The `` element's ID.[/en]
* [ja]ons-toast要素のID。[/ja]
* @param {String} [options.class]
* [en]The `` element's class.[/en]
* [ja]ons-toast要素のclass。[/ja]
* @param {String} [options.modifier]
* [en]Modifier for the element.[/en]
* [ja]トーストのmodifier属性の値を指定します。[/ja]
* @param {Function} [options.callback]
* [en]Function that executes after toast has been hidden.[/en]
* [ja]トーストが閉じられた時に呼び出される関数オブジェクトを指定します。[/ja]
* @description
* [en]
* Display a simple notification toast with an optional button that can be used for simple actions.
*
* It can be called in the following ways:
*
* ```
* ons.notification.toast(message, options);
* ons.notification.toast(options);
* ```
* [/en]
* [ja][/ja]
*/
notification.toast = function (message, options) {
var promise = new Promise(function (resolve) {
util$1.checkMissingImport('Toast'); // Throws error, must be inside promise
options = _normalizeArguments(message, options, {
timeout: 0,
force: false
});
var toast = util$1.createElement('\n \n ' + options.message + '\n ' + (options.buttonLabels ? '' : '') + '\n \n ');
_setAttributes(toast, options);
var finish = function finish(value) {
if (toast) {
toast.hide().then(function () {
if (toast) {
toast.remove();
toast = null;
options.callback(value);
resolve(value);
}
});
}
};
if (options.buttonLabels) {
util$1.findChild(toast._toast, 'button').onclick = function () {
return finish(0);
};
}
document.body.appendChild(toast);
options.compile(toast);
var show = function show() {
toast.parentElement && toast.show(options).then(function () {
if (options.timeout) {
setTimeout(function () {
return finish(-1);
}, options.timeout);
}
});
};
setImmediate(function () {
return options.force ? show() : ToastQueue$1.add(show, promise);
});
});
return promise;
};
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Validate parameters
var checkOptions = function checkOptions(options) {
var err = function err(prop) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Function';
return util$1.throw('"options.' + prop + '" must be an instance of ' + type);
};
var hasOwnProperty = function hasOwnProperty(prop) {
return Object.hasOwnProperty.call(options, prop);
};
var instanceOf = function instanceOf(prop) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Function;
return options[prop] instanceof type;
};
var b = 'buttons',
cb = 'callback',
c = 'compile',
d = 'destroy';
(!hasOwnProperty(b) || !instanceOf(b, Array)) && err(b, 'Array');
hasOwnProperty(cb) && !instanceOf(cb) && err(cb);
hasOwnProperty(c) && !instanceOf(c) && err(c);
hasOwnProperty(d) && !instanceOf(d) && err(d);
};
// Action Sheet
var actionSheet = (function () {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return new Promise(function (resolve) {
util$1.checkMissingImport('ActionSheet');
checkOptions(options);
// Main component
var actionSheet = util$1.createElement('\n \n \n \n ');
// Resolve action and clean up
var finish = function finish(event) {
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
if (actionSheet) {
options.destroy && options.destroy(actionSheet);
actionSheet.removeEventListener('dialog-cancel', finish, false);
actionSheet.remove();
actionSheet = null;
options.callback && options.callback(index);
resolve(index);
}
};
// Link cancel handler
actionSheet.addEventListener('dialog-cancel', finish, false);
// Create buttons and link action handler
var buttons = document.createDocumentFragment();
options.buttons.forEach(function (item, index) {
var buttonOptions = typeof item === 'string' ? { label: item } : _extends({}, item);
if (options.destructive === index) {
buttonOptions.modifier = (buttonOptions.modifier || '') + ' destructive';
}
var button = util$1.createElement('\n \n ' + buttonOptions.label + '\n \n ');
button.onclick = function (event) {
return actionSheet.hide().then(function () {
return finish(event, index);
});
};
buttons.appendChild(button);
});
// Finish component and attach
util$1.findChild(actionSheet, '.action-sheet').appendChild(buttons);
document.body.appendChild(actionSheet);
options.compile && options.compile(el.dialog);
// Show
setImmediate(function () {
return actionSheet.show({
animation: options.animation,
animationOptions: options.animationOptions
});
});
});
});
/**
* MicroEvent - to make any js object an event emitter (server or browser)
*
* - pure javascript - server compatible, browser compatible
* - dont rely on the browser doms
* - super simple - you get it immediately, no mystery, no magic involved
*
* - create a MicroEventDebug with goodies to debug
* - make it safer to use
*/
/** NOTE: This library is customized for Onsen UI. */
var MicroEvent = function MicroEvent() {};
MicroEvent.prototype = {
on: function on(event, fct) {
this._events = this._events || {};
this._events[event] = this._events[event] || [];
this._events[event].push(fct);
},
once: function once(event, fct) {
var self = this;
var wrapper = function wrapper() {
self.off(event, wrapper);
return fct.apply(null, arguments);
};
this.on(event, wrapper);
},
off: function off(event, fct) {
this._events = this._events || {};
if (event in this._events === false) {
return;
}
this._events[event] = this._events[event].filter(function (_fct) {
if (fct) {
return fct !== _fct;
} else {
return false;
}
});
},
emit: function emit(event /* , args... */) {
this._events = this._events || {};
if (event in this._events === false) {
return;
}
for (var i = 0; i < this._events[event].length; i++) {
this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
}
}
};
/**
* mixin will delegate all MicroEvent.js function in the destination object
*
* - require('MicroEvent').mixin(Foobar) will make Foobar able to use MicroEvent
*
* @param {Object} the object which will support MicroEvent
*/
MicroEvent.mixin = function (destObject) {
var props = ['on', 'once', 'off', 'emit'];
for (var i = 0; i < props.length; i++) {
if (typeof destObject === 'function') {
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
} else {
destObject[props[i]] = MicroEvent.prototype[props[i]];
}
}
};
window.MicroEvent = MicroEvent;
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var create = function create() {
/**
* @object ons.orientation
* @category util
* @description
* [en]Utility methods for orientation detection.[/en]
* [ja]画面のオリエンテーション検知のためのユーティリティメソッドを収めているオブジェクトです。[/ja]
*/
var obj = {
/**
* @event change
* @description
* [en]Fired when the device orientation changes.[/en]
* [ja]デバイスのオリエンテーションが変化した際に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Boolean} event.isPortrait
* [en]Will be true if the current orientation is portrait mode.[/en]
* [ja]現在のオリエンテーションがportraitの場合にtrueを返します。[/ja]
*/
/**
* @method on
* @signature on(eventName, listener)
* @description
* [en]Add an event listener.[/en]
* [ja]イベントリスナーを追加します。[/ja]
* @param {String} eventName
* [en]Name of the event.[/en]
* [ja]イベント名を指定します。[/ja]
* @param {Function} listener
* [en]Function to execute when the event is triggered.[/en]
* [ja]このイベントが発火された際に呼び出される関数オブジェクトを指定します。[/ja]
*/
/**
* @method once
* @signature once(eventName, listener)
* @description
* [en]Add an event listener that's only triggered once.[/en]
* [ja]一度だけ呼び出されるイベントリスナーを追加します。[/ja]
* @param {String} eventName
* [en]Name of the event.[/en]
* [ja]イベント名を指定します。[/ja]
* @param {Function} listener
* [en]Function to execute when the event is triggered.[/en]
* [ja]イベントが発火した際に呼び出される関数オブジェクトを指定します。[/ja]
*/
/**
* @method off
* @signature off(eventName, [listener])
* @description
* [en]Remove an event listener. If the listener is not specified all listeners for the event type will be removed.[/en]
* [ja]イベントリスナーを削除します。もしイベントリスナーを指定しなかった場合には、そのイベントに紐づく全てのイベントリスナーが削除されます。[/ja]
* @param {String} eventName
* [en]Name of the event.[/en]
* [ja]イベント名を指定します。[/ja]
* @param {Function} listener
* [en]Function to execute when the event is triggered.[/en]
* [ja]削除するイベントリスナーを指定します。[/ja]
*/
// actual implementation to detect if whether current screen is portrait or not
_isPortrait: false,
/**
* @method isPortrait
* @signature isPortrait()
* @return {Boolean}
* [en]Will be true if the current orientation is portrait mode.[/en]
* [ja]オリエンテーションがportraitモードの場合にtrueになります。[/ja]
* @description
* [en]Returns whether the current screen orientation is portrait or not.[/en]
* [ja]オリエンテーションがportraitモードかどうかを返します。[/ja]
*/
isPortrait: function isPortrait() {
return this._isPortrait();
},
/**
* @method isLandscape
* @signature isLandscape()
* @return {Boolean}
* [en]Will be true if the current orientation is landscape mode.[/en]
* [ja]オリエンテーションがlandscapeモードの場合にtrueになります。[/ja]
* @description
* [en]Returns whether the current screen orientation is landscape or not.[/en]
* [ja]オリエンテーションがlandscapeモードかどうかを返します。[/ja]
*/
isLandscape: function isLandscape() {
return !this.isPortrait();
},
_init: function _init() {
document.addEventListener('DOMContentLoaded', this._onDOMContentLoaded.bind(this), false);
if ('orientation' in window) {
window.addEventListener('orientationchange', this._onOrientationChange.bind(this), false);
} else {
window.addEventListener('resize', this._onResize.bind(this), false);
}
this._isPortrait = function () {
return window.innerHeight > window.innerWidth;
};
return this;
},
_onDOMContentLoaded: function _onDOMContentLoaded() {
this._installIsPortraitImplementation();
this.emit('change', { isPortrait: this.isPortrait() });
},
_installIsPortraitImplementation: function _installIsPortraitImplementation() {
var isPortrait = window.innerWidth < window.innerHeight;
if (!('orientation' in window)) {
this._isPortrait = function () {
return window.innerHeight > window.innerWidth;
};
} else if (window.orientation % 180 === 0) {
this._isPortrait = function () {
return Math.abs(window.orientation % 180) === 0 ? isPortrait : !isPortrait;
};
} else {
this._isPortrait = function () {
return Math.abs(window.orientation % 180) === 90 ? isPortrait : !isPortrait;
};
}
},
_onOrientationChange: function _onOrientationChange() {
var _this = this;
var isPortrait = this._isPortrait();
// Wait for the dimensions to change because
// of Android inconsistency.
var nIter = 0;
var interval = setInterval(function () {
nIter++;
var w = window.innerWidth;
var h = window.innerHeight;
if (isPortrait && w <= h || !isPortrait && w >= h) {
_this.emit('change', { isPortrait: isPortrait });
clearInterval(interval);
} else if (nIter === 50) {
_this.emit('change', { isPortrait: isPortrait });
clearInterval(interval);
}
}, 20);
},
// Run on not mobile browser.
_onResize: function _onResize() {
this.emit('change', { isPortrait: this.isPortrait() });
}
};
MicroEvent.mixin(obj);
return obj;
};
var orientation = create()._init();
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @object ons.modifier
* @category visual
* @description
* [en]
* Utility methods to change modifier attributes of Onsen UI elements..
* [/en]
* [ja][/ja]
* @example
* ons.modifier.add(myOnsInputElement, 'underbar');
* ons.modifier.toggle(myOnsToastElement, 'custom-modifier');
*
*/
var modifier = {
/**
* @method add
* @signature add(element, modifier [, modifier])
* @description
* [en]Add the specified modifiers to the element if they are not already included.[/en]
* [ja][/ja]
* @param {HTMLElement} element
* [en]Target element.[/en]
* [ja][/ja]
* @param {String} modifier
* [en]Name of the modifier.[/en]
* [ja][/ja]
*/
add: function add(element) {
for (var _len = arguments.length, modifiers = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
modifiers[_key - 1] = arguments[_key];
}
return modifiers.forEach(function (modifier) {
return util$1.addModifier(element, modifier);
});
},
/**
* @method remove
* @signature remove(element, modifier [, modifier])
* @description
* [en]Remove the specified modifiers from the element if they are included.[/en]
* [ja][/ja]
* @param {HTMLElement} element
* [en]Target element.[/en]
* [ja][/ja]
* @param {String} modifier
* [en]Name of the modifier.[/en]
* [ja][/ja]
*/
remove: function remove(element) {
for (var _len2 = arguments.length, modifiers = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
modifiers[_key2 - 1] = arguments[_key2];
}
return modifiers.forEach(function (modifier) {
return util$1.removeModifier(element, modifier);
});
},
/**
* @method contains
* @signature contains(element, modifier)
* @description
* [en]Check whether the specified modifier is included in the element.[/en]
* [ja][/ja]
* @param {HTMLElement} element
* [en]Target element.[/en]
* [ja][/ja]
* @param {String} modifier
* [en]Name of the modifier.[/en]
* [ja][/ja]
* @return {Boolean}
* [en]`true` when the specified modifier is found in the element's `modifier` attribute. `false` otherwise.[/en]
* [ja][/ja]
*/
contains: util$1.hasModifier,
/**
* @method toggle
* @signature toggle(element, modifier [, force])
* @description
* [en]Toggle the specified modifier.[/en]
* [ja][/ja]
* @param {HTMLElement} element
* [en]Target element.[/en]
* [ja][/ja]
* @param {String} modifier
* [en]Name of the modifier.[/en]
* [ja][/ja]
* @param {String} force
* [en]If it evaluates to true, add specified modifier value, and if it evaluates to false, remove it.[/en]
* [ja][/ja]
*/
toggle: util$1.toggleModifier
};
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var softwareKeyboard = new MicroEvent();
softwareKeyboard._visible = false;
var onShow = function onShow() {
softwareKeyboard._visible = true;
softwareKeyboard.emit('show');
};
var onHide = function onHide() {
softwareKeyboard._visible = false;
softwareKeyboard.emit('hide');
};
var bindEvents = function bindEvents() {
if (typeof Keyboard !== 'undefined') {
// https://github.com/martinmose/cordova-keyboard/blob/95f3da3a38d8f8e1fa41fbf40145352c13535a00/README.md
Keyboard.onshow = onShow;
Keyboard.onhide = onHide;
softwareKeyboard.emit('init', { visible: Keyboard.isVisible });
return true;
} else if (typeof cordova.plugins !== 'undefined' && typeof cordova.plugins.Keyboard !== 'undefined') {
// https://github.com/driftyco/ionic-plugins-keyboard/blob/ca27ecf/README.md
window.addEventListener('native.keyboardshow', onShow);
window.addEventListener('native.keyboardhide', onHide);
softwareKeyboard.emit('init', { visible: cordova.plugins.Keyboard.isVisible });
return true;
}
return false;
};
var noPluginError = function noPluginError() {
util$1.warn('ons-keyboard: Cordova Keyboard plugin is not present.');
};
document.addEventListener('deviceready', function () {
if (!bindEvents()) {
if (document.querySelector('[ons-keyboard-active]') || document.querySelector('[ons-keyboard-inactive]')) {
noPluginError();
}
softwareKeyboard.on = noPluginError;
}
});
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var generateId = function () {
var i = 0;
return function () {
return i++;
};
}();
/**
* Door locking system.
*
* @param {Object} [options]
* @param {Function} [options.log]
*/
var DoorLock = function () {
function DoorLock() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck(this, DoorLock);
this._lockList = [];
this._waitList = [];
this._log = options.log || function () {};
}
/**
* Register a lock.
*
* @return {Function} Callback for unlocking.
*/
createClass(DoorLock, [{
key: 'lock',
value: function lock() {
var _this = this;
var unlock = function unlock() {
_this._unlock(unlock);
};
unlock.id = generateId();
this._lockList.push(unlock);
this._log('lock: ' + unlock.id);
return unlock;
}
}, {
key: '_unlock',
value: function _unlock(fn) {
var index = this._lockList.indexOf(fn);
if (index === -1) {
throw new Error('This function is not registered in the lock list.');
}
this._lockList.splice(index, 1);
this._log('unlock: ' + fn.id);
this._tryToFreeWaitList();
}
}, {
key: '_tryToFreeWaitList',
value: function _tryToFreeWaitList() {
while (!this.isLocked() && this._waitList.length > 0) {
this._waitList.shift()();
}
}
/**
* Register a callback for waiting unlocked door.
*
* @params {Function} callback Callback on unlocking the door completely.
*/
}, {
key: 'waitUnlock',
value: function waitUnlock(callback) {
if (!(callback instanceof Function)) {
throw new Error('The callback param must be a function.');
}
if (this.isLocked()) {
this._waitList.push(callback);
} else {
callback();
}
}
/**
* @return {Boolean}
*/
}, {
key: 'isLocked',
value: function isLocked() {
return this._lockList.length > 0;
}
}]);
return DoorLock;
}();
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Default implementation for global PageLoader.
function loadPage(_ref, done) {
var page = _ref.page,
parent = _ref.parent,
_ref$params = _ref.params;
internal$1.getPageHTMLAsync(page).then(function (html) {
var pageElement = util$1.createElement(html);
parent.appendChild(pageElement);
done(pageElement);
});
}
function unloadPage(element) {
if (element._destroy instanceof Function) {
element._destroy();
} else {
element.remove();
}
}
var PageLoader = function () {
/**
* @param {Function} [fn] Returns an object that has "element" property and "unload" function.
*/
function PageLoader(loader, unloader) {
classCallCheck(this, PageLoader);
this._loader = loader instanceof Function ? loader : loadPage;
this._unloader = unloader instanceof Function ? unloader : unloadPage;
}
/**
* Set internal loader implementation.
*/
createClass(PageLoader, [{
key: 'load',
/**
* @param {any} options.page
* @param {Element} options.parent A location to load page.
* @param {Object} [options.params] Extra parameters for ons-page.
* @param {Function} done Take an object that has "element" property and "unload" function.
*/
value: function load(_ref2, done) {
var page = _ref2.page,
parent = _ref2.parent,
_ref2$params = _ref2.params,
params = _ref2$params === undefined ? {} : _ref2$params;
this._loader({ page: page, parent: parent, params: params }, function (pageElement) {
if (!(pageElement instanceof Element)) {
throw Error('pageElement must be an instance of Element.');
}
done(pageElement);
});
}
}, {
key: 'unload',
value: function unload(pageElement) {
if (!(pageElement instanceof Element)) {
throw Error('pageElement must be an instance of Element.');
}
this._unloader(pageElement);
}
}, {
key: 'internalLoader',
set: function set$$1(fn) {
if (!(fn instanceof Function)) {
throw Error('First parameter must be an instance of Function');
}
this._loader = fn;
},
get: function get$$1() {
return this._loader;
}
}]);
return PageLoader;
}();
var defaultPageLoader = new PageLoader();
var instantPageLoader = new PageLoader(function (_ref3, done) {
var page = _ref3.page,
parent = _ref3.parent,
_ref3$params = _ref3.params;
var element = util$1.createElement(page.trim());
parent.appendChild(element);
done(element);
}, unloadPage);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @object ons
* @category util
* @description
* [ja]Onsen UIで利用できるグローバルなオブジェクトです。[/ja]
* [en]A global object that's used in Onsen UI. [/en]
*/
var ons$1 = {
animit: Animit,
defaultPageLoader: defaultPageLoader,
elements: onsElements,
GestureDetector: GestureDetector,
modifier: modifier,
notification: notification,
orientation: orientation,
pageAttributeExpression: pageAttributeExpression,
PageLoader: PageLoader,
platform: platform,
softwareKeyboard: softwareKeyboard,
_autoStyle: autoStyle,
_internal: internal$1,
_readyLock: new DoorLock(),
_util: util$1
};
ons$1.platform.select((window.location.search.match(/platform=([\w-]+)/) || [])[1]);
waitDeviceReady();
var readyError = function readyError(after) {
return util$1.throw('This method must be called ' + (after ? 'after' : 'before') + ' ons.isReady() is true');
};
/**
* @method isReady
* @signature isReady()
* @return {Boolean}
* [en]Will be true if Onsen UI is initialized.[/en]
* [ja]初期化されているかどうかを返します。[/ja]
* @description
* [en]Returns true if Onsen UI is initialized.[/en]
* [ja]Onsen UIがすでに初期化されているかどうかを返すメソッドです。[/ja]
*/
ons$1.isReady = function () {
return !ons$1._readyLock.isLocked();
};
/**
* @method isWebView
* @signature isWebView()
* @return {Boolean}
* [en]Will be true if the app is running in Cordova.[/en]
* [ja]Cordovaで実行されている場合にtrueになります。[/ja]
* @description
* [en]Returns true if running inside Cordova.[/en]
* [ja]Cordovaで実行されているかどうかを返すメソッドです。[/ja]
*/
ons$1.isWebView = ons$1.platform.isWebView;
/**
* @method ready
* @signature ready(callback)
* @description
* [ja]アプリの初期化に利用するメソッドです。渡された関数は、Onsen UIの初期化が終了している時点で必ず呼ばれます。[/ja]
* [en]Method used to wait for app initialization. Waits for `DOMContentLoaded` and `deviceready`, when necessary, before executing the callback.[/en]
* @param {Function} callback
* [en]Function that executes after Onsen UI has been initialized.[/en]
* [ja]Onsen UIが初期化が完了した後に呼び出される関数オブジェクトを指定します。[/ja]
*/
ons$1.ready = function (callback) {
if (ons$1.isReady()) {
callback();
} else {
ons$1._readyLock.waitUnlock(callback);
}
};
/**
* @method setDefaultDeviceBackButtonListener
* @signature setDefaultDeviceBackButtonListener(listener)
* @param {Function} listener
* [en]Function that executes when device back button is pressed. Must be called on `ons.ready`.[/en]
* [ja]デバイスのバックボタンが押された時に実行される関数オブジェクトを指定します。[/ja]
* @description
* [en]Set default handler for device back button.[/en]
* [ja]デバイスのバックボタンのためのデフォルトのハンドラを設定します。[/ja]
*/
ons$1.setDefaultDeviceBackButtonListener = function (listener) {
if (!ons$1.isReady()) {
readyError(true);
}
ons$1._defaultDeviceBackButtonHandler.setListener(listener);
};
/**
* @method disableDeviceBackButtonHandler
* @signature disableDeviceBackButtonHandler()
* @description
* [en]Disable device back button event handler. Must be called on `ons.ready`.[/en]
* [ja]デバイスのバックボタンのイベントを受け付けないようにします。[/ja]
*/
ons$1.disableDeviceBackButtonHandler = function () {
if (!ons$1.isReady()) {
readyError(true);
}
internal$1.dbbDispatcher.disable();
};
/**
* @method enableDeviceBackButtonHandler
* @signature enableDeviceBackButtonHandler()
* @description
* [en]Enable device back button event handler. Must be called on `ons.ready`.[/en]
* [ja]デバイスのバックボタンのイベントを受け付けるようにします。[/ja]
*/
ons$1.enableDeviceBackButtonHandler = function () {
if (!ons$1.isReady()) {
readyError(true);
}
internal$1.dbbDispatcher.enable();
};
ons$1.fireDeviceBackButtonEvent = function () {
internal$1.dbbDispatcher.fireDeviceBackButtonEvent();
};
/**
* @method enableAutoStatusBarFill
* @signature enableAutoStatusBarFill()
* @description
* [en]Enable status bar fill feature on iOS7 and above (except for iPhone X). Must be called before `ons.ready`.[/en]
* [ja]iOS7以上(iPhone Xは除く)で、ステータスバー部分の高さを自動的に埋める処理を有効にします。[/ja]
*/
ons$1.enableAutoStatusBarFill = function () {
if (ons$1.isReady()) {
readyError(false);
}
internal$1.config.autoStatusBarFill = true;
};
/**
* @method disableAutoStatusBarFill
* @signature disableAutoStatusBarFill()
* @description
* [en]Disable status bar fill feature on iOS7 and above (except for iPhone X). Must be called before `ons.ready`.[/en]
* [ja]iOS7以上(iPhone Xは除く)で、ステータスバー部分の高さを自動的に埋める処理を無効にします。[/ja]
*/
ons$1.disableAutoStatusBarFill = function () {
if (ons$1.isReady()) {
readyError(false);
}
internal$1.config.autoStatusBarFill = false;
};
/**
* @method mockStatusBar
* @signature mockStatusBar()
* @description
* [en]Creates a static element similar to iOS status bar. Only useful for browser testing. Must be called before `ons.ready`.[/en]
* [ja][/ja]
*/
ons$1.mockStatusBar = function () {
if (ons$1.isReady()) {
readyError(false);
}
var mock = function mock() {
if (!document.body.children[0] || !document.body.children[0].classList.contains('ons-status-bar-mock')) {
var android = platform.isAndroid(),
i = function i(_i) {
return '';
};
var left = android ? i('zmdi-twitter') + ' ' + i('zmdi-google-play') : 'No SIM ' + i('fa-wifi'),
center = android ? '' : '12:28 PM',
right = android ? i('zmdi-network') + ' ' + i('zmdi-wifi') + ' ' + i('zmdi-battery') + ' 12:28 PM' : '80% ' + i('fa-battery-three-quarters');
document.body.insertBefore(util$1.createElement('
' + ('
' + left + '
' + center + '
' + right + '
') + '
'), document.body.firstChild);
}
};
document.body ? mock() : internal$1.waitDOMContentLoaded(mock);
};
/**
* @method disableAnimations
* @signature disableAnimations()
* @description
* [en]Disable all animations. Could be handy for testing and older devices.[/en]
* [ja]アニメーションを全て無効にします。テストの際に便利です。[/ja]
*/
ons$1.disableAnimations = function () {
internal$1.config.animationsDisabled = true;
};
/**
* @method enableAnimations
* @signature enableAnimations()
* @description
* [en]Enable animations (default).[/en]
* [ja]アニメーションを有効にします。[/ja]
*/
ons$1.enableAnimations = function () {
internal$1.config.animationsDisabled = false;
};
ons$1._disableWarnings = function () {
internal$1.config.warningsDisabled = true;
};
ons$1._enableWarnings = function () {
internal$1.config.warningsDisabled = false;
};
/**
* @method disableAutoStyling
* @signature disableAutoStyling()
* @description
* [en]Disable automatic styling.[/en]
* [ja][/ja]
*/
ons$1.disableAutoStyling = autoStyle.disable;
/**
* @method enableAutoStyling
* @signature enableAutoStyling()
* @description
* [en]Enable automatic styling based on OS (default).[/en]
* [ja][/ja]
*/
ons$1.enableAutoStyling = autoStyle.enable;
/**
* @method disableIconAutoPrefix
* @signature disableIconAutoPrefix()
* @description
* [en]Disable adding `fa-` prefix automatically to `ons-icon` classes. Useful when including custom icon packs.[/en]
* [ja][/ja]
*/
ons$1.disableIconAutoPrefix = function () {
util$1.checkMissingImport('Icon');
onsElements.Icon.setAutoPrefix(false);
};
/**
* @method forceUIWebViewScrollFix
* @signature forceUIWebViewScrollFix()
* @param {Boolean} force Enable or disable the fix.
* @description
* [en]Applies a fix for iOS UIWebView which prevents scroll events jumping to pages under the top layer. This may visually affect normal scrolling of UIWebView if you open a dialog/menu before the scroll momentum finished. Disabled by default.[/en]
* [ja][/ja]
*/
ons$1.forceUIWebViewScrollFix = function () {
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
internal$1.config.forceUIWebViewScrollFix = force;
};
/**
* @method forcePlatformStyling
* @signature forcePlatformStyling(platform)
* @description
* [en]Refresh styling for the given platform. Only useful for demos. Use `ons.platform.select(...)` instead for development and production.[/en]
* [ja][/ja]
* @param {string} platform New platform to style the elements.
*/
ons$1.forcePlatformStyling = function (newPlatform) {
ons$1.enableAutoStyling();
ons$1.platform.select(newPlatform || 'ios');
ons$1._util.arrayFrom(document.querySelectorAll('*')).forEach(function (element) {
if (element.tagName.toLowerCase() === 'ons-if') {
element._platformUpdate();
} else if (element.tagName.match(/^ons-/i)) {
autoStyle.prepare(element, true);
if (element.tagName.toLowerCase() === 'ons-tabbar') {
element._updatePosition();
}
}
});
};
/**
* @method preload
* @signature preload(templatePaths)
* @param {String|Array} templatePaths
* [en]Set of HTML file paths containing 'ons-page' elements.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Promise that resolves when all the templates are cached.[/en]
* [ja][/ja]
* @description
* [en]Separated files need to be requested on demand and this can slightly delay pushing new pages. This method requests and caches templates for later use.[/en]
* [ja][/ja]
*/
ons$1.preload = function () {
var templates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return Promise.all((templates instanceof Array ? templates : [templates]).map(function (template) {
if (typeof template !== 'string') {
util$1.throw('Expected string arguments but got ' + (typeof template === 'undefined' ? 'undefined' : _typeof(template)));
}
return internal$1.getTemplateHTMLAsync(template);
}));
};
/**
* @method createElement
* @signature createElement(template, options)
* @param {String} template
* [en]Either an HTML file path, a `` id or an HTML string such as `'
hoge
'`.[/en]
* [ja][/ja]
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {Boolean|HTMLElement} [options.append]
* [en]Whether or not the element should be automatically appended to the DOM. Defaults to `false`. If `true` value is given, `document.body` will be used as the target.[/en]
* [ja][/ja]
* @param {HTMLElement} [options.insertBefore]
* [en]Reference node that becomes the next sibling of the new node (`options.append` element).[/en]
* [ja][/ja]
* @return {HTMLElement|Promise}
* [en]If the provided template was an inline HTML string, it returns the new element. Otherwise, it returns a promise that resolves to the new element.[/en]
* [ja][/ja]
* @description
* [en]Create a new element from a template. Both inline HTML and external files are supported although the return value differs.[/en]
* [ja][/ja]
*/
ons$1.createElement = function (template) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
template = template.trim();
var create = function create(html) {
var element = ons$1._util.createElement(html);
element.remove();
if (options.append) {
var target = options.append instanceof HTMLElement ? options.append : document.body;
target.insertBefore(element, options.insertBefore || null);
options.link instanceof Function && options.link(element);
}
return element;
};
return template.charAt(0) === '<' ? create(template) : internal$1.getPageHTMLAsync(template).then(create);
};
/**
* @method createPopover
* @signature createPopover(page, [options])
* @param {String} page
* [en]Page name. Can be either an HTML file or a containing a component.[/en]
* [ja]pageのURLか、もしくは``で宣言したテンプレートのid属性の値を指定できます。[/ja]
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {Object} [options.parentScope]
* [en]Parent scope of the dialog. Used to bind models and access scope methods from the dialog.[/en]
* [ja]ダイアログ内で利用する親スコープを指定します。ダイアログからモデルやスコープのメソッドにアクセスするのに使います。このパラメータはAngularJSバインディングでのみ利用できます。[/ja]
* @return {Promise}
* [en]Promise object that resolves to the popover component object.[/en]
* [ja]ポップオーバーのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja]
* @description
* [en]Create a popover instance from a template.[/en]
* [ja]テンプレートからポップオーバーのインスタンスを生成します。[/ja]
*/
/**
* @method createDialog
* @signature createDialog(page, [options])
* @param {String} page
* [en]Page name. Can be either an HTML file or an `` containing a component.[/en]
* [ja]pageのURLか、もしくは``で宣言したテンプレートのid属性の値を指定できます。[/ja]
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @return {Promise}
* [en]Promise object that resolves to the dialog component object.[/en]
* [ja]ダイアログのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja]
* @description
* [en]Create a dialog instance from a template.[/en]
* [ja]テンプレートからダイアログのインスタンスを生成します。[/ja]
*/
/**
* @method createAlertDialog
* @signature createAlertDialog(page, [options])
* @param {String} page
* [en]Page name. Can be either an HTML file or an `` containing a component.[/en]
* [ja]pageのURLか、もしくは``で宣言したテンプレートのid属性の値を指定できます。[/ja]
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @return {Promise}
* [en]Promise object that resolves to the alert dialog component object.[/en]
* [ja]ダイアログのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja]
* @description
* [en]Create a alert dialog instance from a template.[/en]
* [ja]テンプレートからアラートダイアログのインスタンスを生成します。[/ja]
*/
ons$1.createPopover = ons$1.createDialog = ons$1.createAlertDialog = function (template) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return ons$1.createElement(template, _extends({ append: true }, options));
};
/**
* @method openActionSheet
* @signature openActionSheet(options)
* @description
* [en]Shows an instant Action Sheet and lets the user choose an action.[/en]
* [ja][/ja]
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {Array} [options.buttons]
* [en]Represent each button of the action sheet following the specified order. Every item can be either a string label or an object containing `label`, `icon` and `modifier` properties.[/en]
* [ja][/ja]
* @param {String} [options.title]
* [en]Optional title for the action sheet.[/en]
* [ja][/ja]
* @param {Number} [options.destructive]
* [en]Optional index of the "destructive" button (only for iOS). It can be specified in the button array as well.[/en]
* [ja][/ja]
* @param {Boolean} [options.cancelable]
* [en]Whether the action sheet can be canceled by tapping on the background mask or not.[/en]
* [ja][/ja]
* @param {String} [options.modifier]
* [en]Modifier attribute of the action sheet. E.g. `'destructive'`.[/en]
* [ja][/ja]
* @param {String} [options.maskColor]
* [en]Optionally change the background mask color.[/en]
* [ja][/ja]
* @param {String} [options.id]
* [en]The element's id attribute.[/en]
* [ja][/ja]
* @param {String} [options.class]
* [en]The element's class attribute.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Will resolve when the action sheet is closed. The resolve value is either the index of the tapped button or -1 when canceled.[/en]
* [ja][/ja]
*/
ons$1.openActionSheet = actionSheet;
/**
* @method resolveLoadingPlaceholder
* @signature resolveLoadingPlaceholder(page)
* @param {String} page
* [en]Page name. Can be either an HTML file or a `` id.[/en]
* [ja]pageのURLか、もしくは``で宣言したテンプレートのid属性の値を指定できます。[/ja]
* @description
* [en]If no page is defined for the `ons-loading-placeholder` attribute it will wait for this method being called before loading the page.[/en]
* [ja]ons-loading-placeholderの属性値としてページが指定されていない場合は、ページロード前に呼ばれるons.resolveLoadingPlaceholder処理が行われるまで表示されません。[/ja]
*/
ons$1.resolveLoadingPlaceholder = function (page, link) {
var elements = ons$1._util.arrayFrom(window.document.querySelectorAll('[ons-loading-placeholder]'));
if (elements.length === 0) {
util$1.throw('No ons-loading-placeholder exists');
}
elements.filter(function (element) {
return !element.getAttribute('page');
}).forEach(function (element) {
element.setAttribute('ons-loading-placeholder', page);
ons$1._resolveLoadingPlaceholder(element, page, link);
});
};
ons$1._setupLoadingPlaceHolders = function () {
ons$1.ready(function () {
var elements = ons$1._util.arrayFrom(window.document.querySelectorAll('[ons-loading-placeholder]'));
elements.forEach(function (element) {
var page = element.getAttribute('ons-loading-placeholder');
if (typeof page === 'string') {
ons$1._resolveLoadingPlaceholder(element, page);
}
});
});
};
ons$1._resolveLoadingPlaceholder = function (parent, page) {
var link = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (el, done) {
return done();
};
page && ons$1.createElement(page).then(function (element) {
element.style.display = 'none';
parent.appendChild(element);
link(element, function () {
while (parent.firstChild && parent.firstChild !== element) {
parent.removeChild(parent.firstChild);
}
element.style.display = '';
});
}).catch(function (error) {
return Promise.reject('Unabled to resolve placeholder: ' + error);
});
};
function waitDeviceReady() {
var unlockDeviceReady = ons$1._readyLock.lock();
window.addEventListener('DOMContentLoaded', function () {
if (ons$1.isWebView()) {
window.document.addEventListener('deviceready', unlockDeviceReady, false);
} else {
unlockDeviceReady();
}
}, false);
}
/**
* @method getScriptPage
* @signature getScriptPage()
* @description
* [en]Access the last created page from the current `script` scope. Only works inside `` tags that are direct children of `ons-page` element. Use this to add lifecycle hooks to a page.[/en]
* [ja][/ja]
* @return {HTMLElement}
* [en]Returns the corresponding page element.[/en]
* [ja][/ja]
*/
var getCS = 'currentScript' in document ? function () {
return document.currentScript;
} : function () {
return document.scripts[document.scripts.length - 1];
};
ons$1.getScriptPage = function () {
return getCS() && /ons-page/i.test(getCS().parentElement.tagName) && getCS().parentElement || null;
};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var fastclick = createCommonjsModule(function (module) {
(function () {
function FastClick(layer, options) {
var oldOnClick;
options = options || {};
/**
* Whether a click is currently being tracked.
*
* @type boolean
*/
this.trackingClick = false;
/**
* Timestamp for when click tracking started.
*
* @type number
*/
this.trackingClickStart = 0;
/**
* The element being tracked for a click.
*
* @type EventTarget
*/
this.targetElement = null;
/**
* X-coordinate of touch start event.
*
* @type number
*/
this.touchStartX = 0;
/**
* Y-coordinate of touch start event.
*
* @type number
*/
this.touchStartY = 0;
/**
* ID of the last touch, retrieved from Touch.identifier.
*
* @type number
*/
this.lastTouchIdentifier = 0;
/**
* Touchmove boundary, beyond which a click will be cancelled.
*
* @type number
*/
this.touchBoundary = options.touchBoundary || 10;
/**
* The FastClick layer.
*
* @type Element
*/
this.layer = layer;
/**
* The minimum time between tap(touchstart and touchend) events
*
* @type number
*/
this.tapDelay = options.tapDelay || 200;
/**
* The maximum time for a tap
*
* @type number
*/
this.tapTimeout = options.tapTimeout || 700;
if (FastClick.notNeeded(layer)) {
return;
}
// Some old versions of Android don't have Function.prototype.bind
function bind(method, context) {
return function () {
return method.apply(context, arguments);
};
}
var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
var context = this;
for (var i = 0, l = methods.length; i < l; i++) {
context[methods[i]] = bind(context[methods[i]], context);
}
// Set up event handlers as required
if (deviceIsAndroid) {
layer.addEventListener('mouseover', this.onMouse, true);
layer.addEventListener('mousedown', this.onMouse, true);
layer.addEventListener('mouseup', this.onMouse, true);
}
layer.addEventListener('click', this.onClick, true);
layer.addEventListener('touchstart', this.onTouchStart, false);
layer.addEventListener('touchmove', this.onTouchMove, false);
layer.addEventListener('touchend', this.onTouchEnd, false);
layer.addEventListener('touchcancel', this.onTouchCancel, false);
// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
// layer when they are cancelled.
if (!Event.prototype.stopImmediatePropagation) {
layer.removeEventListener = function (type, callback, capture) {
var rmv = Node.prototype.removeEventListener;
if (type === 'click') {
rmv.call(layer, type, callback.hijacked || callback, capture);
} else {
rmv.call(layer, type, callback, capture);
}
};
layer.addEventListener = function (type, callback, capture) {
var adv = Node.prototype.addEventListener;
if (type === 'click') {
adv.call(layer, type, callback.hijacked || (callback.hijacked = function (event) {
if (!event.propagationStopped) {
callback(event);
}
}), capture);
} else {
adv.call(layer, type, callback, capture);
}
};
}
// If a handler is already declared in the element's onclick attribute, it will be fired before
// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
// adding it as listener.
if (typeof layer.onclick === 'function') {
// Android browser on at least 3.2 requires a new reference to the function in layer.onclick
// - the old one won't work if passed to addEventListener directly.
oldOnClick = layer.onclick;
layer.addEventListener('click', function (event) {
oldOnClick(event);
}, false);
layer.onclick = null;
}
}
/**
* Windows Phone 8.1 fakes user agent string to look like Android and iPhone.
*
* @type boolean
*/
var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0;
/**
* Android requires exceptions.
*
* @type boolean
*/
var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;
/**
* iOS requires exceptions.
*
* @type boolean
*/
var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;
/**
* iOS 4 requires an exception for select elements.
*
* @type boolean
*/
var deviceIsIOS4 = deviceIsIOS && /OS 4_\d(_\d)?/.test(navigator.userAgent);
/**
* iOS 6.0-7.* requires the target element to be manually derived
*
* @type boolean
*/
var deviceIsIOSWithBadTarget = deviceIsIOS && /OS [6-7]_\d/.test(navigator.userAgent);
/**
* BlackBerry requires exceptions.
*
* @type boolean
*/
var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
/**
* Valid types for text inputs
*
* @type array
*/
var textFields = ['email', 'number', 'password', 'search', 'tel', 'text', 'url'];
/**
* Determine whether a given element requires a native click.
*
* @param {EventTarget|Element} target Target DOM element
* @returns {boolean} Returns true if the element needs a native click
*/
FastClick.prototype.needsClick = function (target) {
switch (target.nodeName.toLowerCase()) {
// Don't send a synthetic click to disabled inputs (issue #62)
case 'button':
case 'select':
case 'textarea':
if (target.disabled) {
return true;
}
break;
case 'input':
// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
if (deviceIsIOS && target.type === 'file' || target.disabled) {
return true;
}
break;
case 'label':
case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames
case 'video':
return true;
}
return (/\bneedsclick\b/.test(target.className)
);
};
/**
* Determine whether a given element requires a call to focus to simulate click into element.
*
* @param {EventTarget|Element} target Target DOM element
* @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
*/
FastClick.prototype.needsFocus = function (target) {
switch (target.nodeName.toLowerCase()) {
case 'textarea':
return true;
case 'select':
return !deviceIsAndroid;
case 'input':
switch (target.type) {
case 'button':
case 'checkbox':
case 'file':
case 'image':
case 'radio':
case 'submit':
return false;
}
// No point in attempting to focus disabled inputs
return !target.disabled && !target.readOnly;
default:
return (/\bneedsfocus\b/.test(target.className)
);
}
};
/**
* Send a click event to the specified element.
*
* @param {EventTarget|Element} targetElement
* @param {Event} event
*/
FastClick.prototype.sendClick = function (targetElement, event) {
var clickEvent, touch;
// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
if (document.activeElement && document.activeElement !== targetElement) {
document.activeElement.blur();
}
touch = event.changedTouches[0];
// Synthesise a click event, with an extra attribute so it can be tracked
clickEvent = document.createEvent('MouseEvents');
clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
clickEvent.forwardedTouchEvent = true;
targetElement.dispatchEvent(clickEvent);
};
FastClick.prototype.determineEventType = function (targetElement) {
//Issue #159: Android Chrome Select Box does not open with a synthetic click event
if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
return 'mousedown';
}
return 'click';
};
/**
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.focus = function (targetElement) {
var length;
// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email' && targetElement.type !== 'number') {
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
/**
* Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
*
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.updateScrollParent = function (targetElement) {
var scrollParent, parentElement;
scrollParent = targetElement.fastClickScrollParent;
// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
// target element was moved to another parent.
if (!scrollParent || !scrollParent.contains(targetElement)) {
parentElement = targetElement;
do {
if (parentElement.scrollHeight > parentElement.offsetHeight) {
scrollParent = parentElement;
targetElement.fastClickScrollParent = parentElement;
break;
}
parentElement = parentElement.parentElement;
} while (parentElement);
}
// Always update the scroll top tracker if possible.
if (scrollParent) {
scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
}
};
/**
* @param {EventTarget} targetElement
* @returns {Element|EventTarget}
*/
FastClick.prototype.getTargetElementFromEventTarget = function (eventTarget) {
// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
if (eventTarget.nodeType === Node.TEXT_NODE) {
return eventTarget.parentNode;
}
return eventTarget;
};
/**
* @param {EventTarget} targetElement
* @returns {boolean}
*/
FastClick.prototype.isTextField = function (targetElement) {
return targetElement.tagName.toLowerCase() === 'textarea' || textFields.indexOf(targetElement.type) !== -1;
};
/**
* On touch start, record the position and scroll offset.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchStart = function (event) {
var targetElement, touch;
// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
if (event.targetTouches.length > 1) {
return true;
}
targetElement = this.getTargetElementFromEventTarget(event.target);
touch = event.targetTouches[0];
// Ignore touches on contenteditable elements to prevent conflict with text selection.
// (For details: https://github.com/ftlabs/fastclick/pull/211 )
if (targetElement.isContentEditable) {
return true;
}
if (deviceIsIOS) {
// Ignore touchstart in focused text field
// Allows normal text selection and commands (select/paste/cut) when a field has focus, while still allowing fast tap-to-focus.
// Without this fix, user needs to tap-and-hold a text field for context menu, and double-tap to select text doesn't work at all.
if (targetElement === document.activeElement && this.isTextField(targetElement)) {
return true;
}
if (!deviceIsIOS4) {
// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
// with the same identifier as the touch event that previously triggered the click that triggered the alert.
// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
// random integers, it's safe to to continue if the identifier is 0 here.
if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
event.preventDefault();
return false;
}
this.lastTouchIdentifier = touch.identifier;
// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
// 1) the user does a fling scroll on the scrollable layer
// 2) the user stops the fling scroll with another tap
// then the event.target of the last 'touchend' event will be the element that was under the user's finger
// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
this.updateScrollParent(targetElement);
}
}
this.trackingClick = true;
this.trackingClickStart = event.timeStamp;
this.targetElement = targetElement;
this.touchStartX = touch.pageX;
this.touchStartY = touch.pageY;
// Prevent phantom clicks on fast double-tap (issue #36)
if (event.timeStamp - this.lastClickTime < this.tapDelay && event.timeStamp - this.lastClickTime > -1) {
event.preventDefault();
}
return true;
};
/**
* Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.touchHasMoved = function (event) {
var touch = event.changedTouches[0],
boundary = this.touchBoundary;
if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
return true;
}
return false;
};
/**
* Update the last position.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchMove = function (event) {
if (!this.trackingClick) {
return true;
}
// If the touch has moved, cancel the click tracking
if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
this.trackingClick = false;
this.targetElement = null;
}
return true;
};
/**
* Attempt to find the labelled control for the given label element.
*
* @param {EventTarget|HTMLLabelElement} labelElement
* @returns {Element|null}
*/
FastClick.prototype.findControl = function (labelElement) {
// Fast path for newer browsers supporting the HTML5 control attribute
if (labelElement.control !== undefined) {
return labelElement.control;
}
// All browsers under test that support touch events also support the HTML5 htmlFor attribute
if (labelElement.htmlFor) {
return document.getElementById(labelElement.htmlFor);
}
// If no for attribute exists, attempt to retrieve the first labellable descendant element
// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
};
/**
* On touch end, determine whether to send a click event at once.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchEnd = function (event) {
var forElement,
trackingClickStart,
targetTagName,
scrollParent,
touch,
targetElement = this.targetElement;
if (!this.trackingClick) {
return true;
}
// Prevent phantom clicks on fast double-tap (issue #36)
if (event.timeStamp - this.lastClickTime < this.tapDelay && event.timeStamp - this.lastClickTime > -1) {
this.cancelNextClick = true;
return true;
}
if (event.timeStamp - this.trackingClickStart > this.tapTimeout) {
return true;
}
// Reset to prevent wrong click cancel on input (issue #156).
this.cancelNextClick = false;
this.lastClickTime = event.timeStamp;
trackingClickStart = this.trackingClickStart;
this.trackingClick = false;
this.trackingClickStart = 0;
// On some iOS devices, the targetElement supplied with the event is invalid if the layer
// is performing a transition or scroll, and has to be re-detected manually. Note that
// for this to function correctly, it must be called *after* the event target is checked!
// See issue #57; also filed as rdar://13048589 .
if (deviceIsIOSWithBadTarget) {
touch = event.changedTouches[0];
// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
}
targetTagName = targetElement.tagName.toLowerCase();
if (targetTagName === 'label') {
forElement = this.findControl(targetElement);
if (forElement) {
this.focus(targetElement);
if (deviceIsAndroid) {
return false;
}
targetElement = forElement;
}
} else if (this.needsFocus(targetElement)) {
// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
if (event.timeStamp - trackingClickStart > 100 || deviceIsIOS && window.top !== window && targetTagName === 'input') {
this.targetElement = null;
return false;
}
this.focus(targetElement);
this.sendClick(targetElement, event);
// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
if (!deviceIsIOS4 || targetTagName !== 'select') {
this.targetElement = null;
event.preventDefault();
}
return false;
}
if (deviceIsIOS && !deviceIsIOS4) {
// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
scrollParent = targetElement.fastClickScrollParent;
if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
return true;
}
}
// Prevent the actual click from going though - unless the target node is marked as requiring
// real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
if (!this.needsClick(targetElement)) {
event.preventDefault();
this.sendClick(targetElement, event);
}
return false;
};
/**
* On touch cancel, stop tracking the click.
*
* @returns {void}
*/
FastClick.prototype.onTouchCancel = function () {
this.trackingClick = false;
this.targetElement = null;
};
/**
* Determine mouse events which should be permitted.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onMouse = function (event) {
// If a target element was never set (because a touch event was never fired) allow the event
if (!this.targetElement) {
return true;
}
if (event.forwardedTouchEvent) {
return true;
}
// Programmatically generated events targeting a specific element should be permitted
if (!event.cancelable) {
return true;
}
// Derive and check the target element to see whether the mouse event needs to be permitted;
// unless explicitly enabled, prevent non-touch click events from triggering actions,
// to prevent ghost/doubleclicks.
if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
// Prevent any user-added listeners declared on FastClick element from being fired.
if (event.stopImmediatePropagation) {
event.stopImmediatePropagation();
} else {
// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
event.propagationStopped = true;
}
// Cancel the event
event.stopPropagation();
event.preventDefault();
return false;
}
// If the mouse event is permitted, return true for the action to go through.
return true;
};
/**
* On actual clicks, determine whether this is a touch-generated click, a click action occurring
* naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
* an actual click which should be permitted.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onClick = function (event) {
var permitted;
// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
if (this.trackingClick) {
this.targetElement = null;
this.trackingClick = false;
return true;
}
// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
if (event.target.type === 'submit' && event.detail === 0) {
return true;
}
permitted = this.onMouse(event);
// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
if (!permitted) {
this.targetElement = null;
}
// If clicks are permitted, return true for the action to go through.
return permitted;
};
/**
* Remove all FastClick's event listeners.
*
* @returns {void}
*/
FastClick.prototype.destroy = function () {
var layer = this.layer;
if (deviceIsAndroid) {
layer.removeEventListener('mouseover', this.onMouse, true);
layer.removeEventListener('mousedown', this.onMouse, true);
layer.removeEventListener('mouseup', this.onMouse, true);
}
layer.removeEventListener('click', this.onClick, true);
layer.removeEventListener('touchstart', this.onTouchStart, false);
layer.removeEventListener('touchmove', this.onTouchMove, false);
layer.removeEventListener('touchend', this.onTouchEnd, false);
layer.removeEventListener('touchcancel', this.onTouchCancel, false);
};
/**
* Check whether FastClick is needed.
*
* @param {Element} layer The layer to listen on
*/
FastClick.notNeeded = function (layer) {
var metaViewport;
var chromeVersion;
var blackberryVersion;
var firefoxVersion;
// Devices that don't support touch don't need FastClick
if (typeof window.ontouchstart === 'undefined') {
return true;
}
// Chrome version - zero for other browsers
chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1];
if (chromeVersion) {
if (deviceIsAndroid) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {
// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
return true;
}
// Chrome 32 and above with width=device-width or less don't need FastClick
if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
return true;
}
}
// Chrome desktop doesn't need FastClick (issue #15)
} else {
return true;
}
}
if (deviceIsBlackBerry10) {
blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
// BlackBerry 10.3+ does not require Fastclick library.
// https://github.com/ftlabs/fastclick/issues/251
if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {
// user-scalable=no eliminates click delay.
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
return true;
}
// width=device-width (or less than device-width) eliminates click delay.
if (document.documentElement.scrollWidth <= window.outerWidth) {
return true;
}
}
}
}
// IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)
if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {
return true;
}
// Firefox version - zero for other browsers
firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1];
if (firefoxVersion >= 27) {
// Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {
return true;
}
}
// IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
// http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
return true;
}
return false;
};
/**
* Factory method for creating a FastClick object
*
* @param {Element} layer The layer to listen on
* @param {Object} [options={}] The options to override the defaults
*/
FastClick.attach = function (layer, options) {
return new FastClick(layer, options);
};
if (typeof undefined === 'function' && _typeof(undefined.amd) === 'object' && undefined.amd) {
// AMD. Register as an anonymous module.
undefined(function () {
return FastClick;
});
} else if ('object' !== 'undefined' && module.exports) {
module.exports = FastClick.attach;
module.exports.FastClick = FastClick;
} else {
window.FastClick = FastClick;
}
})();
});
var fastclick_1 = fastclick.FastClick;
// For @onsenui/custom-elements
if (window.customElements) {
// even if native CE1 impl exists, use polyfill
window.customElements.forcePolyfill = true;
}
var _global = createCommonjsModule(function (module) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self
// eslint-disable-next-line no-new-func
: Function('return this')();
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
});
var _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.5.1' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
});
var _core_1 = _core.version;
var _isObject = function _isObject(it) {
return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function';
};
var _anObject = function _anObject(it) {
if (!_isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
var _fails = function _fails(exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
// Thank's IE8 for his funny defineProperty
var _descriptors = !_fails(function () {
return Object.defineProperty({}, 'a', { get: function get() {
return 7;
} }).a != 7;
});
var document$1 = _global.document;
// typeof document.createElement is 'object' in old IE
var is = _isObject(document$1) && _isObject(document$1.createElement);
var _domCreate = function _domCreate(it) {
return is ? document$1.createElement(it) : {};
};
var _ie8DomDefine = !_descriptors && !_fails(function () {
return Object.defineProperty(_domCreate('div'), 'a', { get: function get() {
return 7;
} }).a != 7;
});
// 7.1.1 ToPrimitive(input [, PreferredType])
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
var _toPrimitive = function _toPrimitive(it, S) {
if (!_isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
var dP = Object.defineProperty;
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
_anObject(O);
P = _toPrimitive(P, true);
_anObject(Attributes);
if (_ie8DomDefine) try {
return dP(O, P, Attributes);
} catch (e) {/* empty */}
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var _objectDp = {
f: f
};
var _propertyDesc = function _propertyDesc(bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var _hide = _descriptors ? function (object, key, value) {
return _objectDp.f(object, key, _propertyDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var hasOwnProperty = {}.hasOwnProperty;
var _has = function _has(it, key) {
return hasOwnProperty.call(it, key);
};
var id = 0;
var px = Math.random();
var _uid = function _uid(key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
var _redefine = createCommonjsModule(function (module) {
var SRC = _uid('src');
var TO_STRING = 'toString';
var $toString = Function[TO_STRING];
var TPL = ('' + $toString).split(TO_STRING);
_core.inspectSource = function (it) {
return $toString.call(it);
};
(module.exports = function (O, key, val, safe) {
var isFunction = typeof val == 'function';
if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
if (O[key] === val) return;
if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
if (O === _global) {
O[key] = val;
} else if (!safe) {
delete O[key];
_hide(O, key, val);
} else if (O[key]) {
O[key] = val;
} else {
_hide(O, key, val);
}
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString() {
return typeof this == 'function' && this[SRC] || $toString.call(this);
});
});
var _aFunction = function _aFunction(it) {
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
return it;
};
// optional / simple context binding
var _ctx = function _ctx(fn, that, length) {
_aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1:
return function (a) {
return fn.call(that, a);
};
case 2:
return function (a, b) {
return fn.call(that, a, b);
};
case 3:
return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function () /* ...args */{
return fn.apply(that, arguments);
};
};
var PROTOTYPE = 'prototype';
var $export = function $export(type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
var key, own, out, exp;
if (IS_GLOBAL) source = name;
for (key in source) {
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
// export native or passed
out = (own ? target : source)[key];
// bind timers to global for call from export context
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
// extend global
if (target) _redefine(target, key, out, type & $export.U);
// export
if (exports[key] != out) _hide(exports, key, exp);
if (IS_PROTO && expProto[key] != out) expProto[key] = out;
}
};
_global.core = _core;
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
var _export = $export;
var f$2 = {}.propertyIsEnumerable;
var _objectPie = {
f: f$2
};
var toString = {}.toString;
var _cof = function _cof(it) {
return toString.call(it).slice(8, -1);
};
// fallback for non-array-like ES3 and non-enumerable old V8 strings
// eslint-disable-next-line no-prototype-builtins
var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
return _cof(it) == 'String' ? it.split('') : Object(it);
};
// 7.2.1 RequireObjectCoercible(argument)
var _defined = function _defined(it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
// to indexed object, toObject with fallback for non-array-like ES3 strings
var _toIobject = function _toIobject(it) {
return _iobject(_defined(it));
};
var gOPD = Object.getOwnPropertyDescriptor;
var f$1 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
O = _toIobject(O);
P = _toPrimitive(P, true);
if (_ie8DomDefine) try {
return gOPD(O, P);
} catch (e) {/* empty */}
if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
};
var _objectGopd = {
f: f$1
};
// Works with __proto__ only. Old v8 can't work with null proto objects.
/* eslint-disable no-proto */
var check = function check(O, proto) {
_anObject(O);
if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
};
var _setProto = {
set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
function (test, buggy, set) {
try {
set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2);
set(test, []);
buggy = !(test instanceof Array);
} catch (e) {
buggy = true;
}
return function setPrototypeOf(O, proto) {
check(O, proto);
if (buggy) O.__proto__ = proto;else set(O, proto);
return O;
};
}({}, false) : undefined),
check: check
};
// 19.1.3.19 Object.setPrototypeOf(O, proto)
_export(_export.S, 'Object', { setPrototypeOf: _setProto.set });
var setPrototypeOf = _core.Object.setPrototypeOf;
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
var _shared = function _shared(key) {
return store[key] || (store[key] = {});
};
var _wks = createCommonjsModule(function (module) {
var store = _shared('wks');
var _Symbol = _global.Symbol;
var USE_SYMBOL = typeof _Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : _uid)('Symbol.' + name));
};
$exports.store = store;
});
// getting tag from 19.1.3.6 Object.prototype.toString()
var TAG = _wks('toStringTag');
// ES3 wrong here
var ARG = _cof(function () {
return arguments;
}()) == 'Arguments';
// fallback for IE11 Script Access Denied error
var tryGet = function tryGet(it, key) {
try {
return it[key];
} catch (e) {/* empty */}
};
var _classof = function _classof(it) {
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null'
// @@toStringTag case
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
// builtinTag case
: ARG ? _cof(O)
// ES3 arguments fallback
: (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
// 19.1.3.6 Object.prototype.toString()
var test = {};
test[_wks('toStringTag')] = 'z';
if (test + '' != '[object z]') {
_redefine(Object.prototype, 'toString', function toString() {
return '[object ' + _classof(this) + ']';
}, true);
}
// 7.1.4 ToInteger
var ceil = Math.ceil;
var floor = Math.floor;
var _toInteger = function _toInteger(it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
// true -> String#at
// false -> String#codePointAt
var _stringAt = function _stringAt(TO_STRING) {
return function (that, pos) {
var s = String(_defined(that));
var i = _toInteger(pos);
var l = s.length;
var a, b;
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
var _library = false;
var _iterators = {};
// 7.1.15 ToLength
var min = Math.min;
var _toLength = function _toLength(it) {
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
var max = Math.max;
var min$1 = Math.min;
var _toAbsoluteIndex = function _toAbsoluteIndex(index, length) {
index = _toInteger(index);
return index < 0 ? max(index + length, 0) : min$1(index, length);
};
// false -> Array#indexOf
// true -> Array#includes
var _arrayIncludes = function _arrayIncludes(IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = _toIobject($this);
var length = _toLength(O.length);
var index = _toAbsoluteIndex(fromIndex, length);
var value;
// Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++];
// eslint-disable-next-line no-self-compare
if (value != value) return true;
// Array#indexOf ignores holes, Array#includes - not
} else for (; length > index; index++) {
if (IS_INCLUDES || index in O) {
if (O[index] === el) return IS_INCLUDES || index || 0;
}
}return !IS_INCLUDES && -1;
};
};
var shared = _shared('keys');
var _sharedKey = function _sharedKey(key) {
return shared[key] || (shared[key] = _uid(key));
};
var arrayIndexOf = _arrayIncludes(false);
var IE_PROTO$1 = _sharedKey('IE_PROTO');
var _objectKeysInternal = function _objectKeysInternal(object, names) {
var O = _toIobject(object);
var i = 0;
var result = [];
var key;
for (key in O) {
if (key != IE_PROTO$1) _has(O, key) && result.push(key);
} // Don't enum bug & hidden keys
while (names.length > i) {
if (_has(O, key = names[i++])) {
~arrayIndexOf(result, key) || result.push(key);
}
}return result;
};
// IE 8- don't enum bug keys
var _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var _objectKeys = Object.keys || function keys(O) {
return _objectKeysInternal(O, _enumBugKeys);
};
var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
_anObject(O);
var keys = _objectKeys(Properties);
var length = keys.length;
var i = 0;
var P;
while (length > i) {
_objectDp.f(O, P = keys[i++], Properties[P]);
}return O;
};
var document$2 = _global.document;
var _html = document$2 && document$2.documentElement;
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var IE_PROTO = _sharedKey('IE_PROTO');
var Empty = function Empty() {/* empty */};
var PROTOTYPE$1 = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var _createDict = function createDict() {
// Thrash, waste and sodomy: IE GC bug
var iframe = _domCreate('iframe');
var i = _enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
_html.appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
_createDict = iframeDocument.F;
while (i--) {
delete _createDict[PROTOTYPE$1][_enumBugKeys[i]];
}return _createDict();
};
var _objectCreate = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE$1] = _anObject(O);
result = new Empty();
Empty[PROTOTYPE$1] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = _createDict();
return Properties === undefined ? result : _objectDps(result, Properties);
};
var def = _objectDp.f;
var TAG$1 = _wks('toStringTag');
var _setToStringTag = function _setToStringTag(it, tag, stat) {
if (it && !_has(it = stat ? it : it.prototype, TAG$1)) def(it, TAG$1, { configurable: true, value: tag });
};
var IteratorPrototype = {};
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
_hide(IteratorPrototype, _wks('iterator'), function () {
return this;
});
var _iterCreate = function _iterCreate(Constructor, NAME, next) {
Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
_setToStringTag(Constructor, NAME + ' Iterator');
};
// 7.1.13 ToObject(argument)
var _toObject = function _toObject(it) {
return Object(_defined(it));
};
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
var IE_PROTO$2 = _sharedKey('IE_PROTO');
var ObjectProto = Object.prototype;
var _objectGpo = Object.getPrototypeOf || function (O) {
O = _toObject(O);
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
return O.constructor.prototype;
}return O instanceof Object ? ObjectProto : null;
};
var ITERATOR = _wks('iterator');
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
var FF_ITERATOR = '@@iterator';
var KEYS = 'keys';
var VALUES = 'values';
var returnThis = function returnThis() {
return this;
};
var _iterDefine = function _iterDefine(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
_iterCreate(Constructor, NAME, next);
var getMethod = function getMethod(kind) {
if (!BUGGY && kind in proto) return proto[kind];
switch (kind) {
case KEYS:
return function keys() {
return new Constructor(this, kind);
};
case VALUES:
return function values() {
return new Constructor(this, kind);
};
}return function entries() {
return new Constructor(this, kind);
};
};
var TAG = NAME + ' Iterator';
var DEF_VALUES = DEFAULT == VALUES;
var VALUES_BUG = false;
var proto = Base.prototype;
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
var $default = $native || getMethod(DEFAULT);
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
var methods, key, IteratorPrototype;
// Fix native
if ($anyNative) {
IteratorPrototype = _objectGpo($anyNative.call(new Base()));
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
// Set @@toStringTag to native iterators
_setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if (!_library && !_has(IteratorPrototype, ITERATOR)) _hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if (DEF_VALUES && $native && $native.name !== VALUES) {
VALUES_BUG = true;
$default = function values() {
return $native.call(this);
};
}
// Define iterator
if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
_hide(proto, ITERATOR, $default);
}
// Plug for library
_iterators[NAME] = $default;
_iterators[TAG] = returnThis;
if (DEFAULT) {
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if (FORCED) for (key in methods) {
if (!(key in proto)) _redefine(proto, key, methods[key]);
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
var $at = _stringAt(true);
// 21.1.3.27 String.prototype[@@iterator]()
_iterDefine(String, 'String', function (iterated) {
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function () {
var O = this._t;
var index = this._i;
var point;
if (index >= O.length) return { value: undefined, done: true };
point = $at(O, index);
this._i += point.length;
return { value: point, done: false };
});
// 22.1.3.31 Array.prototype[@@unscopables]
var UNSCOPABLES = _wks('unscopables');
var ArrayProto = Array.prototype;
if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
var _addToUnscopables = function _addToUnscopables(key) {
ArrayProto[UNSCOPABLES][key] = true;
};
var _iterStep = function _iterStep(done, value) {
return { value: value, done: !!done };
};
// 22.1.3.4 Array.prototype.entries()
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
this._t = _toIobject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function () {
var O = this._t;
var kind = this._k;
var index = this._i++;
if (!O || index >= O.length) {
this._t = undefined;
return _iterStep(1);
}
if (kind == 'keys') return _iterStep(0, index);
if (kind == 'values') return _iterStep(0, O[index]);
return _iterStep(0, [index, O[index]]);
}, 'values');
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
_iterators.Arguments = _iterators.Array;
_addToUnscopables('keys');
_addToUnscopables('values');
_addToUnscopables('entries');
var ITERATOR$1 = _wks('iterator');
var TO_STRING_TAG = _wks('toStringTag');
var ArrayValues = _iterators.Array;
var DOMIterables = {
CSSRuleList: true, // TODO: Not spec compliant, should be false.
CSSStyleDeclaration: false,
CSSValueList: false,
ClientRectList: false,
DOMRectList: false,
DOMStringList: false,
DOMTokenList: true,
DataTransferItemList: false,
FileList: false,
HTMLAllCollection: false,
HTMLCollection: false,
HTMLFormElement: false,
HTMLSelectElement: false,
MediaList: true, // TODO: Not spec compliant, should be false.
MimeTypeArray: false,
NamedNodeMap: false,
NodeList: true,
PaintRequestList: false,
Plugin: false,
PluginArray: false,
SVGLengthList: false,
SVGNumberList: false,
SVGPathSegList: false,
SVGPointList: false,
SVGStringList: false,
SVGTransformList: false,
SourceBufferList: false,
StyleSheetList: true, // TODO: Not spec compliant, should be false.
TextTrackCueList: false,
TextTrackList: false,
TouchList: false
};
for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
var NAME = collections[i];
var explicit = DOMIterables[NAME];
var Collection = _global[NAME];
var proto = Collection && Collection.prototype;
var key;
if (proto) {
if (!proto[ITERATOR$1]) _hide(proto, ITERATOR$1, ArrayValues);
if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
_iterators[NAME] = ArrayValues;
if (explicit) for (key in es6_array_iterator) {
if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
}
}
}
var _redefineAll = function _redefineAll(target, src, safe) {
for (var key in src) {
_redefine(target, key, src[key], safe);
}return target;
};
var _anInstance = function _anInstance(it, Constructor, name, forbiddenField) {
if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
throw TypeError(name + ': incorrect invocation!');
}return it;
};
// call something on iterator step with safe closing on error
var _iterCall = function _iterCall(iterator, fn, value, entries) {
try {
return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
// 7.4.6 IteratorClose(iterator, completion)
} catch (e) {
var ret = iterator['return'];
if (ret !== undefined) _anObject(ret.call(iterator));
throw e;
}
};
// check on default Array iterator
var ITERATOR$2 = _wks('iterator');
var ArrayProto$1 = Array.prototype;
var _isArrayIter = function _isArrayIter(it) {
return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR$2] === it);
};
var ITERATOR$3 = _wks('iterator');
var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
if (it != undefined) return it[ITERATOR$3] || it['@@iterator'] || _iterators[_classof(it)];
};
var _forOf = createCommonjsModule(function (module) {
var BREAK = {};
var RETURN = {};
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
var iterFn = ITERATOR ? function () {
return iterable;
} : core_getIteratorMethod(iterable);
var f = _ctx(fn, that, entries ? 2 : 1);
var index = 0;
var length, step, iterator, result;
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
// fast case for arrays with default iterator
if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
if (result === BREAK || result === RETURN) return result;
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
result = _iterCall(iterator, f, step.value, entries);
if (result === BREAK || result === RETURN) return result;
}
};
exports.BREAK = BREAK;
exports.RETURN = RETURN;
});
var SPECIES = _wks('species');
var _setSpecies = function _setSpecies(KEY) {
var C = _global[KEY];
if (_descriptors && C && !C[SPECIES]) _objectDp.f(C, SPECIES, {
configurable: true,
get: function get() {
return this;
}
});
};
var _meta = createCommonjsModule(function (module) {
var META = _uid('meta');
var setDesc = _objectDp.f;
var id = 0;
var isExtensible = Object.isExtensible || function () {
return true;
};
var FREEZE = !_fails(function () {
return isExtensible(Object.preventExtensions({}));
});
var setMeta = function setMeta(it) {
setDesc(it, META, { value: {
i: 'O' + ++id, // object ID
w: {} // weak collections IDs
} });
};
var fastKey = function fastKey(it, create) {
// return primitive with prefix
if (!_isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
if (!_has(it, META)) {
// can't set metadata to uncaught frozen object
if (!isExtensible(it)) return 'F';
// not necessary to add metadata
if (!create) return 'E';
// add missing metadata
setMeta(it);
// return object ID
}return it[META].i;
};
var getWeak = function getWeak(it, create) {
if (!_has(it, META)) {
// can't set metadata to uncaught frozen object
if (!isExtensible(it)) return true;
// not necessary to add metadata
if (!create) return false;
// add missing metadata
setMeta(it);
// return hash weak collections IDs
}return it[META].w;
};
// add metadata on freeze-family methods calling
var onFreeze = function onFreeze(it) {
if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
return it;
};
var meta = module.exports = {
KEY: META,
NEED: false,
fastKey: fastKey,
getWeak: getWeak,
onFreeze: onFreeze
};
});
var _meta_1 = _meta.KEY;
var _meta_2 = _meta.NEED;
var _meta_3 = _meta.fastKey;
var _meta_4 = _meta.getWeak;
var _meta_5 = _meta.onFreeze;
var _validateCollection = function _validateCollection(it, TYPE) {
if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
return it;
};
var dP$1 = _objectDp.f;
var fastKey = _meta.fastKey;
var SIZE = _descriptors ? '_s' : 'size';
var getEntry = function getEntry(that, key) {
// fast case
var index = fastKey(key);
var entry;
if (index !== 'F') return that._i[index];
// frozen object case
for (entry = that._f; entry; entry = entry.n) {
if (entry.k == key) return entry;
}
};
var _collectionStrong = {
getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
var C = wrapper(function (that, iterable) {
_anInstance(that, C, NAME, '_i');
that._t = NAME; // collection type
that._i = _objectCreate(null); // index
that._f = undefined; // first entry
that._l = undefined; // last entry
that[SIZE] = 0; // size
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
});
_redefineAll(C.prototype, {
// 23.1.3.1 Map.prototype.clear()
// 23.2.3.2 Set.prototype.clear()
clear: function clear() {
for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
entry.r = true;
if (entry.p) entry.p = entry.p.n = undefined;
delete data[entry.i];
}
that._f = that._l = undefined;
that[SIZE] = 0;
},
// 23.1.3.3 Map.prototype.delete(key)
// 23.2.3.4 Set.prototype.delete(value)
'delete': function _delete(key) {
var that = _validateCollection(this, NAME);
var entry = getEntry(that, key);
if (entry) {
var next = entry.n;
var prev = entry.p;
delete that._i[entry.i];
entry.r = true;
if (prev) prev.n = next;
if (next) next.p = prev;
if (that._f == entry) that._f = next;
if (that._l == entry) that._l = prev;
that[SIZE]--;
}return !!entry;
},
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
forEach: function forEach(callbackfn /* , that = undefined */) {
_validateCollection(this, NAME);
var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
var entry;
while (entry = entry ? entry.n : this._f) {
f(entry.v, entry.k, this);
// revert to the last existing entry
while (entry && entry.r) {
entry = entry.p;
}
}
},
// 23.1.3.7 Map.prototype.has(key)
// 23.2.3.7 Set.prototype.has(value)
has: function has(key) {
return !!getEntry(_validateCollection(this, NAME), key);
}
});
if (_descriptors) dP$1(C.prototype, 'size', {
get: function get() {
return _validateCollection(this, NAME)[SIZE];
}
});
return C;
},
def: function def(that, key, value) {
var entry = getEntry(that, key);
var prev, index;
// change existing entry
if (entry) {
entry.v = value;
// create new entry
} else {
that._l = entry = {
i: index = fastKey(key, true), // <- index
k: key, // <- key
v: value, // <- value
p: prev = that._l, // <- previous entry
n: undefined, // <- next entry
r: false // <- removed
};
if (!that._f) that._f = entry;
if (prev) prev.n = entry;
that[SIZE]++;
// add to index
if (index !== 'F') that._i[index] = entry;
}return that;
},
getEntry: getEntry,
setStrong: function setStrong(C, NAME, IS_MAP) {
// add .keys, .values, .entries, [@@iterator]
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
_iterDefine(C, NAME, function (iterated, kind) {
this._t = _validateCollection(iterated, NAME); // target
this._k = kind; // kind
this._l = undefined; // previous
}, function () {
var that = this;
var kind = that._k;
var entry = that._l;
// revert to the last existing entry
while (entry && entry.r) {
entry = entry.p;
} // get next entry
if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
// or finish the iteration
that._t = undefined;
return _iterStep(1);
}
// return step by kind
if (kind == 'keys') return _iterStep(0, entry.k);
if (kind == 'values') return _iterStep(0, entry.v);
return _iterStep(0, [entry.k, entry.v]);
}, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
// add [@@species], 23.1.2.2, 23.2.2.2
_setSpecies(NAME);
}
};
var ITERATOR$4 = _wks('iterator');
var SAFE_CLOSING = false;
try {
var riter = [7][ITERATOR$4]();
riter['return'] = function () {
SAFE_CLOSING = true;
};
// eslint-disable-next-line no-throw-literal
} catch (e) {/* empty */}
var _iterDetect = function _iterDetect(exec, skipClosing) {
if (!skipClosing && !SAFE_CLOSING) return false;
var safe = false;
try {
var arr = [7];
var iter = arr[ITERATOR$4]();
iter.next = function () {
return { done: safe = true };
};
arr[ITERATOR$4] = function () {
return iter;
};
exec(arr);
} catch (e) {/* empty */}
return safe;
};
var setPrototypeOf$2 = _setProto.set;
var _inheritIfRequired = function _inheritIfRequired(that, target, C) {
var S = target.constructor;
var P;
if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf$2) {
setPrototypeOf$2(that, P);
}return that;
};
var _collection = function _collection(NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
var Base = _global[NAME];
var C = Base;
var ADDER = IS_MAP ? 'set' : 'add';
var proto = C && C.prototype;
var O = {};
var fixMethod = function fixMethod(KEY) {
var fn = proto[KEY];
_redefine(proto, KEY, KEY == 'delete' ? function (a) {
return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
} : KEY == 'has' ? function has(a) {
return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
} : KEY == 'get' ? function get(a) {
return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
} : KEY == 'add' ? function add(a) {
fn.call(this, a === 0 ? 0 : a);return this;
} : function set(a, b) {
fn.call(this, a === 0 ? 0 : a, b);return this;
});
};
if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
new C().entries().next();
}))) {
// create collection constructor
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
_redefineAll(C.prototype, methods);
_meta.NEED = true;
} else {
var instance = new C();
// early implementations not supports chaining
var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
// V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
var THROWS_ON_PRIMITIVES = _fails(function () {
instance.has(1);
});
// most early implementations doesn't supports iterables, most modern - not close it correctly
var ACCEPT_ITERABLES = _iterDetect(function (iter) {
new C(iter);
}); // eslint-disable-line no-new
// for early implementations -0 and +0 not the same
var BUGGY_ZERO = !IS_WEAK && _fails(function () {
// V8 ~ Chromium 42- fails only with 5+ elements
var $instance = new C();
var index = 5;
while (index--) {
$instance[ADDER](index, index);
}return !$instance.has(-0);
});
if (!ACCEPT_ITERABLES) {
C = wrapper(function (target, iterable) {
_anInstance(target, C, NAME);
var that = _inheritIfRequired(new Base(), target, C);
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
return that;
});
C.prototype = proto;
proto.constructor = C;
}
if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
fixMethod('delete');
fixMethod('has');
IS_MAP && fixMethod('get');
}
if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
// weak collections should not contains .clear method
if (IS_WEAK && proto.clear) delete proto.clear;
}
_setToStringTag(C, NAME);
O[NAME] = C;
_export(_export.G + _export.W + _export.F * (C != Base), O);
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
return C;
};
var SET = 'Set';
// 23.2 Set Objects
var es6_set = _collection(SET, function (get) {
return function Set() {
return get(this, arguments.length > 0 ? arguments[0] : undefined);
};
}, {
// 23.2.3.1 Set.prototype.add(value)
add: function add(value) {
return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value);
}
}, _collectionStrong);
var _arrayFromIterable = function _arrayFromIterable(iter, ITERATOR) {
var result = [];
_forOf(iter, false, result.push, result, ITERATOR);
return result;
};
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var _collectionToJson = function _collectionToJson(NAME) {
return function toJSON() {
if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
return _arrayFromIterable(this);
};
};
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
_export(_export.P + _export.R, 'Set', { toJSON: _collectionToJson('Set') });
// https://tc39.github.io/proposal-setmap-offrom/
var _setCollectionOf = function _setCollectionOf(COLLECTION) {
_export(_export.S, COLLECTION, { of: function of() {
var length = arguments.length;
var A = Array(length);
while (length--) {
A[length] = arguments[length];
}return new this(A);
} });
};
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
_setCollectionOf('Set');
// https://tc39.github.io/proposal-setmap-offrom/
var _setCollectionFrom = function _setCollectionFrom(COLLECTION) {
_export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
var mapFn = arguments[1];
var mapping, A, n, cb;
_aFunction(this);
mapping = mapFn !== undefined;
if (mapping) _aFunction(mapFn);
if (source == undefined) return new this();
A = [];
if (mapping) {
n = 0;
cb = _ctx(mapFn, arguments[2], 2);
_forOf(source, false, function (nextItem) {
A.push(cb(nextItem, n++));
});
} else {
_forOf(source, false, A.push, A);
}
return new this(A);
} });
};
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
_setCollectionFrom('Set');
var set$1 = _core.Set;
var MAP = 'Map';
// 23.1 Map Objects
var es6_map = _collection(MAP, function (get) {
return function Map() {
return get(this, arguments.length > 0 ? arguments[0] : undefined);
};
}, {
// 23.1.3.6 Map.prototype.get(key)
get: function get(key) {
var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key);
return entry && entry.v;
},
// 23.1.3.9 Map.prototype.set(key, value)
set: function set(key, value) {
return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value);
}
}, _collectionStrong, true);
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
_export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') });
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
_setCollectionOf('Map');
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
_setCollectionFrom('Map');
var map = _core.Map;
// 7.2.2 IsArray(argument)
var _isArray = Array.isArray || function isArray(arg) {
return _cof(arg) == 'Array';
};
var SPECIES$1 = _wks('species');
var _arraySpeciesConstructor = function _arraySpeciesConstructor(original) {
var C;
if (_isArray(original)) {
C = original.constructor;
// cross-realm fallback
if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
if (_isObject(C)) {
C = C[SPECIES$1];
if (C === null) C = undefined;
}
}return C === undefined ? Array : C;
};
// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
var _arraySpeciesCreate = function _arraySpeciesCreate(original, length) {
return new (_arraySpeciesConstructor(original))(length);
};
// 0 -> Array#forEach
// 1 -> Array#map
// 2 -> Array#filter
// 3 -> Array#some
// 4 -> Array#every
// 5 -> Array#find
// 6 -> Array#findIndex
var _arrayMethods = function _arrayMethods(TYPE, $create) {
var IS_MAP = TYPE == 1;
var IS_FILTER = TYPE == 2;
var IS_SOME = TYPE == 3;
var IS_EVERY = TYPE == 4;
var IS_FIND_INDEX = TYPE == 6;
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
var create = $create || _arraySpeciesCreate;
return function ($this, callbackfn, that) {
var O = _toObject($this);
var self = _iobject(O);
var f = _ctx(callbackfn, that, 3);
var length = _toLength(self.length);
var index = 0;
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
var val, res;
for (; length > index; index++) {
if (NO_HOLES || index in self) {
val = self[index];
res = f(val, index, O);
if (TYPE) {
if (IS_MAP) result[index] = res; // map
else if (res) switch (TYPE) {
case 3:
return true; // some
case 5:
return val; // find
case 6:
return index; // findIndex
case 2:
result.push(val); // filter
} else if (IS_EVERY) return false; // every
}
}
}return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
};
};
var f$3 = Object.getOwnPropertySymbols;
var _objectGops = {
f: f$3
};
// 19.1.2.1 Object.assign(target, source, ...)
var $assign = Object.assign;
// should work with symbols and should have deterministic property order (V8 bug)
var _objectAssign = !$assign || _fails(function () {
var A = {};
var B = {};
// eslint-disable-next-line no-undef
var S = Symbol();
var K = 'abcdefghijklmnopqrst';
A[S] = 7;
K.split('').forEach(function (k) {
B[k] = k;
});
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
}) ? function assign(target, source) {
// eslint-disable-line no-unused-vars
var T = _toObject(target);
var aLen = arguments.length;
var index = 1;
var getSymbols = _objectGops.f;
var isEnum = _objectPie.f;
while (aLen > index) {
var S = _iobject(arguments[index++]);
var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) {
if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
}
}return T;
} : $assign;
var getWeak = _meta.getWeak;
var arrayFind = _arrayMethods(5);
var arrayFindIndex = _arrayMethods(6);
var id$1 = 0;
// fallback for uncaught frozen keys
var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
return that._l || (that._l = new UncaughtFrozenStore());
};
var UncaughtFrozenStore = function UncaughtFrozenStore() {
this.a = [];
};
var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
return arrayFind(store.a, function (it) {
return it[0] === key;
});
};
UncaughtFrozenStore.prototype = {
get: function get(key) {
var entry = findUncaughtFrozen(this, key);
if (entry) return entry[1];
},
has: function has(key) {
return !!findUncaughtFrozen(this, key);
},
set: function set(key, value) {
var entry = findUncaughtFrozen(this, key);
if (entry) entry[1] = value;else this.a.push([key, value]);
},
'delete': function _delete(key) {
var index = arrayFindIndex(this.a, function (it) {
return it[0] === key;
});
if (~index) this.a.splice(index, 1);
return !!~index;
}
};
var _collectionWeak = {
getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
var C = wrapper(function (that, iterable) {
_anInstance(that, C, NAME, '_i');
that._t = NAME; // collection type
that._i = id$1++; // collection id
that._l = undefined; // leak store for uncaught frozen objects
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
});
_redefineAll(C.prototype, {
// 23.3.3.2 WeakMap.prototype.delete(key)
// 23.4.3.3 WeakSet.prototype.delete(value)
'delete': function _delete(key) {
if (!_isObject(key)) return false;
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME))['delete'](key);
return data && _has(data, this._i) && delete data[this._i];
},
// 23.3.3.4 WeakMap.prototype.has(key)
// 23.4.3.4 WeakSet.prototype.has(value)
has: function has(key) {
if (!_isObject(key)) return false;
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME)).has(key);
return data && _has(data, this._i);
}
});
return C;
},
def: function def(that, key, value) {
var data = getWeak(_anObject(key), true);
if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
return that;
},
ufstore: uncaughtFrozenStore
};
var es6_weakMap = createCommonjsModule(function (module) {
var each = _arrayMethods(0);
var WEAK_MAP = 'WeakMap';
var getWeak = _meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = _collectionWeak.ufstore;
var tmp = {};
var InternalMap;
var wrapper = function wrapper(get) {
return function WeakMap() {
return get(this, arguments.length > 0 ? arguments[0] : undefined);
};
};
var methods = {
// 23.3.3.3 WeakMap.prototype.get(key)
get: function get(key) {
if (_isObject(key)) {
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(_validateCollection(this, WEAK_MAP)).get(key);
return data ? data[this._i] : undefined;
}
},
// 23.3.3.5 WeakMap.prototype.set(key, value)
set: function set(key, value) {
return _collectionWeak.def(_validateCollection(this, WEAK_MAP), key, value);
}
};
// 23.3 WeakMap Objects
var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true);
// IE11 WeakMap frozen keys fix
if (_fails(function () {
return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7;
})) {
InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP);
_objectAssign(InternalMap.prototype, methods);
_meta.NEED = true;
each(['delete', 'has', 'get', 'set'], function (key) {
var proto = $WeakMap.prototype;
var method = proto[key];
_redefine(proto, key, function (a, b) {
// store frozen objects on internal weakmap shim
if (_isObject(a) && !isExtensible(a)) {
if (!this._f) this._f = new InternalMap();
var result = this._f[key](a, b);
return key == 'set' ? this : result;
// store all the rest on native weakmap
}return method.call(this, a, b);
});
});
}
});
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of
_setCollectionOf('WeakMap');
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from
_setCollectionFrom('WeakMap');
var weakMap = _core.WeakMap;
var _createProperty = function _createProperty(object, index, value) {
if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));else object[index] = value;
};
_export(_export.S + _export.F * !_iterDetect(function (iter) {
}), 'Array', {
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
var O = _toObject(arrayLike);
var C = typeof this == 'function' ? this : Array;
var aLen = arguments.length;
var mapfn = aLen > 1 ? arguments[1] : undefined;
var mapping = mapfn !== undefined;
var index = 0;
var iterFn = core_getIteratorMethod(O);
var length, result, step, iterator;
if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
// if object isn't iterable or it's array with default iterator - use simple case
if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) {
for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
_createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value);
}
} else {
length = _toLength(O.length);
for (result = new C(length); length > index; index++) {
_createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
}
}
result.length = index;
return result;
}
});
var from$1 = _core.Array.from;
var reservedTagList = new Set(['annotation-xml', 'color-profile', 'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', 'font-face-name', 'missing-glyph']);
/**
* @param {string} localName
* @returns {boolean}
*/
function isValidCustomElementName(localName) {
var reserved = reservedTagList.has(localName);
var validForm = /^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(localName);
return !reserved && validForm;
}
/**
* @private
* @param {!Node} node
* @return {boolean}
*/
function isConnected(node) {
// Use `Node#isConnected`, if defined.
var nativeValue = node.isConnected;
if (nativeValue !== undefined) {
return nativeValue;
}
/** @type {?Node|undefined} */
var current = node;
while (current && !(current.__CE_isImportDocument || current instanceof Document)) {
current = current.parentNode || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined);
}
return !!(current && (current.__CE_isImportDocument || current instanceof Document));
}
/**
* @param {!Node} root
* @param {!Node} start
* @return {?Node}
*/
function nextSiblingOrAncestorSibling(root, start) {
var node = start;
while (node && node !== root && !node.nextSibling) {
node = node.parentNode;
}
return !node || node === root ? null : node.nextSibling;
}
/**
* @param {!Node} root
* @param {!Node} start
* @return {?Node}
*/
function nextNode(root, start) {
return start.firstChild ? start.firstChild : nextSiblingOrAncestorSibling(root, start);
}
/**
* @param {!Node} root
* @param {!function(!Element)} callback
* @param {!Set=} visitedImports
*/
function walkDeepDescendantElements(root, callback) {
var visitedImports = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
var node = root;
while (node) {
if (node.nodeType === Node.ELEMENT_NODE) {
var element = /** @type {!Element} */node;
callback(element);
var localName = element.localName;
if (localName === 'link' && element.getAttribute('rel') === 'import') {
// If this import (polyfilled or not) has it's root node available,
// walk it.
var importNode = /** @type {!Node} */element.import;
if (importNode instanceof Node && !visitedImports.has(importNode)) {
// Prevent multiple walks of the same import root.
visitedImports.add(importNode);
for (var child = importNode.firstChild; child; child = child.nextSibling) {
walkDeepDescendantElements(child, callback, visitedImports);
}
}
// Ignore descendants of import links to prevent attempting to walk the
// elements created by the HTML Imports polyfill that we just walked
// above.
node = nextSiblingOrAncestorSibling(root, element);
continue;
} else if (localName === 'template') {
// Ignore descendants of templates. There shouldn't be any descendants
// because they will be moved into `.content` during construction in
// browsers that support template but, in case they exist and are still
// waiting to be moved by a polyfill, they will be ignored.
node = nextSiblingOrAncestorSibling(root, element);
continue;
}
// Walk shadow roots.
var shadowRoot = element.__CE_shadowRoot;
if (shadowRoot) {
for (var _child = shadowRoot.firstChild; _child; _child = _child.nextSibling) {
walkDeepDescendantElements(_child, callback, visitedImports);
}
}
}
node = nextNode(root, node);
}
}
/**
* Used to suppress Closure's "Modifying the prototype is only allowed if the
* constructor is in the same scope" warning without using
* `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.
*
* @param {!Object} destination
* @param {string} name
* @param {*} value
*/
function setPropertyUnchecked(destination, name, value) {
destination[name] = value;
}
/**
* @enum {number}
*/
var CustomElementState = {
custom: 1,
failed: 2
};
var CustomElementInternals = function () {
function CustomElementInternals() {
classCallCheck(this, CustomElementInternals);
/** @type {!Map} */
this._localNameToDefinition = new Map();
/** @type {!Map} */
this._constructorToDefinition = new Map();
/** @type {!Array} */
this._patches = [];
/** @type {boolean} */
this._hasPatches = false;
}
/**
* @param {string} localName
* @param {!CustomElementDefinition} definition
*/
createClass(CustomElementInternals, [{
key: 'setDefinition',
value: function setDefinition(localName, definition) {
this._localNameToDefinition.set(localName, definition);
this._constructorToDefinition.set(definition.constructor, definition);
}
/**
* @param {string} localName
* @return {!CustomElementDefinition|undefined}
*/
}, {
key: 'localNameToDefinition',
value: function localNameToDefinition(localName) {
return this._localNameToDefinition.get(localName);
}
/**
* @param {!Function} constructor
* @return {!CustomElementDefinition|undefined}
*/
}, {
key: 'constructorToDefinition',
value: function constructorToDefinition(constructor) {
return this._constructorToDefinition.get(constructor);
}
/**
* @param {!function(!Node)} listener
*/
}, {
key: 'addPatch',
value: function addPatch(listener) {
this._hasPatches = true;
this._patches.push(listener);
}
/**
* @param {!Node} node
*/
}, {
key: 'patchTree',
value: function patchTree(node) {
var _this = this;
if (!this._hasPatches) return;
walkDeepDescendantElements(node, function (element) {
return _this.patch(element);
});
}
/**
* @param {!Node} node
*/
}, {
key: 'patch',
value: function patch(node) {
if (!this._hasPatches) return;
if (node.__CE_patched) return;
node.__CE_patched = true;
for (var i = 0; i < this._patches.length; i++) {
this._patches[i](node);
}
}
/**
* @param {!Node} root
*/
}, {
key: 'connectTree',
value: function connectTree(root) {
var elements = [];
walkDeepDescendantElements(root, function (element) {
return elements.push(element);
});
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.__CE_state === CustomElementState.custom) {
if (isConnected(element)) {
this.connectedCallback(element);
}
} else {
this.upgradeElement(element);
}
}
}
/**
* @param {!Node} root
*/
}, {
key: 'disconnectTree',
value: function disconnectTree(root) {
var elements = [];
walkDeepDescendantElements(root, function (element) {
return elements.push(element);
});
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.__CE_state === CustomElementState.custom) {
this.disconnectedCallback(element);
}
}
}
/**
* Upgrades all uncustomized custom elements at and below a root node for
* which there is a definition. When custom element reaction callbacks are
* assumed to be called synchronously (which, by the current DOM / HTML spec
* definitions, they are *not*), callbacks for both elements customized
* synchronously by the parser and elements being upgraded occur in the same
* relative order.
*
* NOTE: This function, when used to simulate the construction of a tree that
* is already created but not customized (i.e. by the parser), does *not*
* prevent the element from reading the 'final' (true) state of the tree. For
* example, the element, during truly synchronous parsing / construction would
* see that it contains no children as they have not yet been inserted.
* However, this function does not modify the tree, the element will
* (incorrectly) have children. Additionally, self-modification restrictions
* for custom element constructors imposed by the DOM spec are *not* enforced.
*
*
* The following nested list shows the steps extending down from the HTML
* spec's parsing section that cause elements to be synchronously created and
* upgraded:
*
* The "in body" insertion mode:
* https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
* - Switch on token:
* .. other cases ..
* -> Any other start tag
* - [Insert an HTML element](below) for the token.
*
* Insert an HTML element:
* https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element
* - Insert a foreign element for the token in the HTML namespace:
* https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element
* - Create an element for a token:
* https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token
* - Will execute script flag is true?
* - (Element queue pushed to the custom element reactions stack.)
* - Create an element:
* https://dom.spec.whatwg.org/#concept-create-element
* - Sync CE flag is true?
* - Constructor called.
* - Self-modification restrictions enforced.
* - Sync CE flag is false?
* - (Upgrade reaction enqueued.)
* - Attributes appended to element.
* (`attributeChangedCallback` reactions enqueued.)
* - Will execute script flag is true?
* - (Element queue popped from the custom element reactions stack.
* Reactions in the popped stack are invoked.)
* - (Element queue pushed to the custom element reactions stack.)
* - Insert the element:
* https://dom.spec.whatwg.org/#concept-node-insert
* - Shadow-including descendants are connected. During parsing
* construction, there are no shadow-*excluding* descendants.
* However, the constructor may have validly attached a shadow
* tree to itself and added descendants to that shadow tree.
* (`connectedCallback` reactions enqueued.)
* - (Element queue popped from the custom element reactions stack.
* Reactions in the popped stack are invoked.)
*
* @param {!Node} root
* @param {!Set=} visitedImports
*/
}, {
key: 'patchAndUpgradeTree',
value: function patchAndUpgradeTree(root) {
var _this2 = this;
var visitedImports = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
var elements = [];
var gatherElements = function gatherElements(element) {
if (element.localName === 'link' && element.getAttribute('rel') === 'import') {
// The HTML Imports polyfill sets a descendant element of the link to
// the `import` property, specifically this is *not* a Document.
var importNode = /** @type {?Node} */element.import;
if (importNode instanceof Node && importNode.readyState === 'complete') {
importNode.__CE_isImportDocument = true;
// Connected links are associated with the registry.
importNode.__CE_hasRegistry = true;
} else {
// If this link's import root is not available, its contents can't be
// walked. Wait for 'load' and walk it when it's ready.
element.addEventListener('load', function () {
var importNode = /** @type {!Node} */element.import;
if (importNode.__CE_documentLoadHandled) return;
importNode.__CE_documentLoadHandled = true;
importNode.__CE_isImportDocument = true;
// Connected links are associated with the registry.
importNode.__CE_hasRegistry = true;
// Clone the `visitedImports` set that was populated sync during
// the `patchAndUpgradeTree` call that caused this 'load' handler to
// be added. Then, remove *this* link's import node so that we can
// walk that import again, even if it was partially walked later
// during the same `patchAndUpgradeTree` call.
visitedImports.delete(importNode);
_this2.patchAndUpgradeTree(importNode, visitedImports);
});
}
} else {
elements.push(element);
}
};
// `walkDeepDescendantElements` populates (and internally checks against)
// `visitedImports` when traversing a loaded import.
walkDeepDescendantElements(root, gatherElements, visitedImports);
if (this._hasPatches) {
for (var i = 0; i < elements.length; i++) {
this.patch(elements[i]);
}
}
for (var _i = 0; _i < elements.length; _i++) {
this.upgradeElement(elements[_i]);
}
}
/**
* @param {!Element} element
*/
}, {
key: 'upgradeElement',
value: function upgradeElement(element) {
var currentState = element.__CE_state;
if (currentState !== undefined) return;
var definition = this.localNameToDefinition(element.localName);
if (!definition) return;
definition.constructionStack.push(element);
var constructor = definition.constructor;
try {
try {
var result = new constructor();
if (result !== element) {
throw new Error('The custom element constructor did not produce the element being upgraded.');
}
} finally {
definition.constructionStack.pop();
}
} catch (e) {
element.__CE_state = CustomElementState.failed;
throw e;
}
element.__CE_state = CustomElementState.custom;
element.__CE_definition = definition;
if (definition.attributeChangedCallback) {
var observedAttributes = definition.observedAttributes;
for (var i = 0; i < observedAttributes.length; i++) {
var name = observedAttributes[i];
var value = element.getAttribute(name);
if (value !== null) {
this.attributeChangedCallback(element, name, null, value, null);
}
}
}
if (isConnected(element)) {
this.connectedCallback(element);
}
}
/**
* @param {!Element} element
*/
}, {
key: 'connectedCallback',
value: function connectedCallback(element) {
var definition = element.__CE_definition;
if (definition.connectedCallback) {
definition.connectedCallback.call(element);
}
element.__CE_isConnectedCallbackCalled = true;
}
/**
* @param {!Element} element
*/
}, {
key: 'disconnectedCallback',
value: function disconnectedCallback(element) {
if (!element.__CE_isConnectedCallbackCalled) {
this.connectedCallback(element);
}
var definition = element.__CE_definition;
if (definition.disconnectedCallback) {
definition.disconnectedCallback.call(element);
}
element.__CE_isConnectedCallbackCalled = undefined;
}
/**
* @param {!Element} element
* @param {string} name
* @param {?string} oldValue
* @param {?string} newValue
* @param {?string} namespace
*/
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(element, name, oldValue, newValue, namespace) {
var definition = element.__CE_definition;
if (definition.attributeChangedCallback && definition.observedAttributes.indexOf(name) > -1) {
definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);
}
}
}]);
return CustomElementInternals;
}();
var DocumentConstructionObserver = function () {
function DocumentConstructionObserver(internals, doc) {
classCallCheck(this, DocumentConstructionObserver);
/**
* @type {!CustomElementInternals}
*/
this._internals = internals;
/**
* @type {!Document}
*/
this._document = doc;
/**
* @type {MutationObserver|undefined}
*/
this._observer = undefined;
// Simulate tree construction for all currently accessible nodes in the
// document.
this._internals.patchAndUpgradeTree(this._document);
if (this._document.readyState === 'loading') {
this._observer = new MutationObserver(this._handleMutations.bind(this));
// Nodes created by the parser are given to the observer *before* the next
// task runs. Inline scripts are run in a new task. This means that the
// observer will be able to handle the newly parsed nodes before the inline
// script is run.
this._observer.observe(this._document, {
childList: true,
subtree: true
});
}
}
createClass(DocumentConstructionObserver, [{
key: 'disconnect',
value: function disconnect() {
if (this._observer) {
this._observer.disconnect();
}
}
/**
* @param {!Array} mutations
*/
}, {
key: '_handleMutations',
value: function _handleMutations(mutations) {
// Once the document's `readyState` is 'interactive' or 'complete', all new
// nodes created within that document will be the result of script and
// should be handled by patching.
var readyState = this._document.readyState;
if (readyState === 'interactive' || readyState === 'complete') {
this.disconnect();
}
for (var i = 0; i < mutations.length; i++) {
var addedNodes = mutations[i].addedNodes;
for (var j = 0; j < addedNodes.length; j++) {
var node = addedNodes[j];
this._internals.patchAndUpgradeTree(node);
}
}
}
}]);
return DocumentConstructionObserver;
}();
/**
* @template T
*/
var Deferred = function () {
function Deferred() {
var _this = this;
classCallCheck(this, Deferred);
/**
* @private
* @type {T|undefined}
*/
this._value = undefined;
/**
* @private
* @type {Function|undefined}
*/
this._resolve = undefined;
/**
* @private
* @type {!Promise}
*/
this._promise = new Promise(function (resolve) {
_this._resolve = resolve;
if (_this._value) {
resolve(_this._value);
}
});
}
/**
* @param {T} value
*/
createClass(Deferred, [{
key: 'resolve',
value: function resolve(value) {
if (this._value) {
throw new Error('Already resolved.');
}
this._value = value;
if (this._resolve) {
this._resolve(value);
}
}
/**
* @return {!Promise}
*/
}, {
key: 'toPromise',
value: function toPromise() {
return this._promise;
}
}]);
return Deferred;
}();
/**
* @unrestricted
*/
var CustomElementRegistry = function () {
/**
* @param {!CustomElementInternals} internals
*/
function CustomElementRegistry(internals) {
classCallCheck(this, CustomElementRegistry);
/**
* @private
* @type {boolean}
*/
this._elementDefinitionIsRunning = false;
/**
* @private
* @type {!CustomElementInternals}
*/
this._internals = internals;
/**
* @private
* @type {!Map>}
*/
this._whenDefinedDeferred = new Map();
/**
* The default flush callback triggers the document walk synchronously.
* @private
* @type {!Function}
*/
this._flushCallback = function (fn) {
return fn();
};
/**
* @private
* @type {boolean}
*/
this._flushPending = false;
/**
* @private
* @type {!Array}
*/
this._unflushedLocalNames = [];
/**
* @private
* @type {!DocumentConstructionObserver}
*/
this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);
}
/**
* @param {string} localName
* @param {!Function} constructor
*/
createClass(CustomElementRegistry, [{
key: 'define',
value: function define(localName, constructor) {
var _this = this;
if (!(constructor instanceof Function)) {
throw new TypeError('Custom element constructors must be functions.');
}
if (!isValidCustomElementName(localName)) {
throw new SyntaxError('The element name \'' + localName + '\' is not valid.');
}
if (this._internals.localNameToDefinition(localName)) {
throw new Error('A custom element with name \'' + localName + '\' has already been defined.');
}
if (this._elementDefinitionIsRunning) {
throw new Error('A custom element is already being defined.');
}
this._elementDefinitionIsRunning = true;
var connectedCallback = void 0;
var disconnectedCallback = void 0;
var adoptedCallback = void 0;
var attributeChangedCallback = void 0;
var observedAttributes = void 0;
try {
var getCallback = function getCallback(name) {
var callbackValue = prototype[name];
if (callbackValue !== undefined && !(callbackValue instanceof Function)) {
throw new Error('The \'' + name + '\' callback must be a function.');
}
return callbackValue;
};
/** @type {!Object} */
var prototype = constructor.prototype;
if (!(prototype instanceof Object)) {
throw new TypeError('The custom element constructor\'s prototype is not an object.');
}
connectedCallback = getCallback('connectedCallback');
disconnectedCallback = getCallback('disconnectedCallback');
adoptedCallback = getCallback('adoptedCallback');
attributeChangedCallback = getCallback('attributeChangedCallback');
observedAttributes = constructor['observedAttributes'] || [];
} catch (e) {
return;
} finally {
this._elementDefinitionIsRunning = false;
}
var definition = {
localName: localName,
constructor: constructor,
connectedCallback: connectedCallback,
disconnectedCallback: disconnectedCallback,
adoptedCallback: adoptedCallback,
attributeChangedCallback: attributeChangedCallback,
observedAttributes: observedAttributes,
constructionStack: []
};
this._internals.setDefinition(localName, definition);
this._unflushedLocalNames.push(localName);
// If we've already called the flush callback and it hasn't called back yet,
// don't call it again.
if (!this._flushPending) {
this._flushPending = true;
this._flushCallback(function () {
return _this._flush();
});
}
}
}, {
key: '_flush',
value: function _flush() {
// If no new definitions were defined, don't attempt to flush. This could
// happen if a flush callback keeps the function it is given and calls it
// multiple times.
if (this._flushPending === false) return;
this._flushPending = false;
this._internals.patchAndUpgradeTree(document);
while (this._unflushedLocalNames.length > 0) {
var localName = this._unflushedLocalNames.shift();
var deferred = this._whenDefinedDeferred.get(localName);
if (deferred) {
deferred.resolve(undefined);
}
}
}
/**
* @param {string} localName
* @return {Function|undefined}
*/
}, {
key: 'get',
value: function get$$1(localName) {
var definition = this._internals.localNameToDefinition(localName);
if (definition) {
return definition.constructor;
}
return undefined;
}
/**
* @param {string} localName
* @return {!Promise}
*/
}, {
key: 'whenDefined',
value: function whenDefined(localName) {
if (!isValidCustomElementName(localName)) {
return Promise.reject(new SyntaxError('\'' + localName + '\' is not a valid custom element name.'));
}
var prior = this._whenDefinedDeferred.get(localName);
if (prior) {
return prior.toPromise();
}
var deferred = new Deferred();
this._whenDefinedDeferred.set(localName, deferred);
var definition = this._internals.localNameToDefinition(localName);
// Resolve immediately only if the given local name has a definition *and*
// the full document walk to upgrade elements with that local name has
// already happened.
if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {
deferred.resolve(undefined);
}
return deferred.toPromise();
}
}, {
key: 'polyfillWrapFlushCallback',
value: function polyfillWrapFlushCallback(outer) {
this._documentConstructionObserver.disconnect();
var inner = this._flushCallback;
this._flushCallback = function (flush) {
return outer(function () {
return inner(flush);
});
};
}
}]);
return CustomElementRegistry;
}();
window['CustomElementRegistry'] = CustomElementRegistry;
CustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;
CustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;
CustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;
CustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;
var Native = {
Document_createElement: window.Document.prototype.createElement,
Document_createElementNS: window.Document.prototype.createElementNS,
Document_importNode: window.Document.prototype.importNode,
Document_prepend: window.Document.prototype['prepend'],
Document_append: window.Document.prototype['append'],
Node_cloneNode: window.Node.prototype.cloneNode,
Node_appendChild: window.Node.prototype.appendChild,
Node_insertBefore: window.Node.prototype.insertBefore,
Node_removeChild: window.Node.prototype.removeChild,
Node_replaceChild: window.Node.prototype.replaceChild,
Node_textContent: Object.getOwnPropertyDescriptor(window.Node.prototype, 'textContent'),
Element_attachShadow: window.Element.prototype['attachShadow'],
Element_innerHTML: Object.getOwnPropertyDescriptor(window.Element.prototype, 'innerHTML'),
Element_getAttribute: window.Element.prototype.getAttribute,
Element_setAttribute: window.Element.prototype.setAttribute,
Element_removeAttribute: window.Element.prototype.removeAttribute,
Element_getAttributeNS: window.Element.prototype.getAttributeNS,
Element_setAttributeNS: window.Element.prototype.setAttributeNS,
Element_removeAttributeNS: window.Element.prototype.removeAttributeNS,
Element_insertAdjacentElement: window.Element.prototype['insertAdjacentElement'],
Element_prepend: window.Element.prototype['prepend'],
Element_append: window.Element.prototype['append'],
Element_before: window.Element.prototype['before'],
Element_after: window.Element.prototype['after'],
Element_replaceWith: window.Element.prototype['replaceWith'],
Element_remove: window.Element.prototype['remove'],
HTMLElement: window.HTMLElement,
HTMLElement_innerHTML: Object.getOwnPropertyDescriptor(window.HTMLElement.prototype, 'innerHTML'),
HTMLElement_insertAdjacentElement: window.HTMLElement.prototype['insertAdjacentElement']
};
/**
* This class exists only to work around Closure's lack of a way to describe
* singletons. It represents the 'already constructed marker' used in custom
* element construction stacks.
*
* https://html.spec.whatwg.org/#concept-already-constructed-marker
*/
var AlreadyConstructedMarker = function AlreadyConstructedMarker() {
classCallCheck(this, AlreadyConstructedMarker);
};
var AlreadyConstructedMarker$1 = new AlreadyConstructedMarker();
/**
* @param {!CustomElementInternals} internals
*/
var PatchHTMLElement = function (internals) {
window['HTMLElement'] = function () {
/**
* @type {function(new: HTMLElement): !HTMLElement}
*/
function HTMLElement() {
// This should really be `new.target` but `new.target` can't be emulated
// in ES5. Assuming the user keeps the default value of the constructor's
// prototype's `constructor` property, this is equivalent.
/** @type {!Function} */
var constructor = this.constructor;
var definition = internals.constructorToDefinition(constructor);
if (!definition) {
throw new Error('The custom element being constructed was not registered with `customElements`.');
}
var constructionStack = definition.constructionStack;
if (constructionStack.length === 0) {
var _element = Native.Document_createElement.call(document, definition.localName);
Object.setPrototypeOf(_element, constructor.prototype);
_element.__CE_state = CustomElementState.custom;
_element.__CE_definition = definition;
internals.patch(_element);
return _element;
}
var lastIndex = constructionStack.length - 1;
var element = constructionStack[lastIndex];
if (element === AlreadyConstructedMarker$1) {
throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');
}
constructionStack[lastIndex] = AlreadyConstructedMarker$1;
Object.setPrototypeOf(element, constructor.prototype);
internals.patch( /** @type {!HTMLElement} */element);
return element;
}
HTMLElement.prototype = Native.HTMLElement.prototype;
return HTMLElement;
}();
};
/**
* @param {!CustomElementInternals} internals
* @param {!Object} destination
* @param {!ParentNodeNativeMethods} builtIn
*/
var PatchParentNode = function (internals, destination, builtIn) {
/**
* @param {...(!Node|string)} nodes
*/
destination['prepend'] = function () {
for (var _len = arguments.length, nodes = Array(_len), _key = 0; _key < _len; _key++) {
nodes[_key] = arguments[_key];
}
// TODO: Fix this for when one of `nodes` is a DocumentFragment!
var connectedBefore = /** @type {!Array} */nodes.filter(function (node) {
// DocumentFragments are not connected and will not be added to the list.
return node instanceof Node && isConnected(node);
});
builtIn.prepend.apply(this, nodes);
for (var i = 0; i < connectedBefore.length; i++) {
internals.disconnectTree(connectedBefore[i]);
}
if (isConnected(this)) {
for (var _i = 0; _i < nodes.length; _i++) {
var node = nodes[_i];
if (node instanceof Element) {
internals.connectTree(node);
}
}
}
};
/**
* @param {...(!Node|string)} nodes
*/
destination['append'] = function () {
for (var _len2 = arguments.length, nodes = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
nodes[_key2] = arguments[_key2];
}
// TODO: Fix this for when one of `nodes` is a DocumentFragment!
var connectedBefore = /** @type {!Array} */nodes.filter(function (node) {
// DocumentFragments are not connected and will not be added to the list.
return node instanceof Node && isConnected(node);
});
builtIn.append.apply(this, nodes);
for (var i = 0; i < connectedBefore.length; i++) {
internals.disconnectTree(connectedBefore[i]);
}
if (isConnected(this)) {
for (var _i2 = 0; _i2 < nodes.length; _i2++) {
var node = nodes[_i2];
if (node instanceof Element) {
internals.connectTree(node);
}
}
}
};
};
/**
* @param {!CustomElementInternals} internals
*/
var PatchDocument = function (internals) {
setPropertyUnchecked(Document.prototype, 'createElement',
/**
* @this {Document}
* @param {string} localName
* @return {!Element}
*/
function (localName) {
// Only create custom elements if this document is associated with the registry.
if (this.__CE_hasRegistry) {
var definition = internals.localNameToDefinition(localName);
if (definition) {
return new definition.constructor();
}
}
var result = /** @type {!Element} */
Native.Document_createElement.call(this, localName);
internals.patch(result);
return result;
});
setPropertyUnchecked(Document.prototype, 'importNode',
/**
* @this {Document}
* @param {!Node} node
* @param {boolean=} deep
* @return {!Node}
*/
function (node, deep) {
var clone = Native.Document_importNode.call(this, node, deep);
// Only create custom elements if this document is associated with the registry.
if (!this.__CE_hasRegistry) {
internals.patchTree(clone);
} else {
internals.patchAndUpgradeTree(clone);
}
return clone;
});
var NS_HTML = "http://www.w3.org/1999/xhtml";
setPropertyUnchecked(Document.prototype, 'createElementNS',
/**
* @this {Document}
* @param {?string} namespace
* @param {string} localName
* @return {!Element}
*/
function (namespace, localName) {
// Only create custom elements if this document is associated with the registry.
if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {
var definition = internals.localNameToDefinition(localName);
if (definition) {
return new definition.constructor();
}
}
var result = /** @type {!Element} */
Native.Document_createElementNS.call(this, namespace, localName);
internals.patch(result);
return result;
});
PatchParentNode(internals, Document.prototype, {
prepend: Native.Document_prepend,
append: Native.Document_append
});
};
/**
* @param {!CustomElementInternals} internals
*/
var PatchNode = function (internals) {
// `Node#nodeValue` is implemented on `Attr`.
// `Node#textContent` is implemented on `Attr`, `Element`.
setPropertyUnchecked(Node.prototype, 'insertBefore',
/**
* @this {Node}
* @param {!Node} node
* @param {?Node} refNode
* @return {!Node}
*/
function (node, refNode) {
if (node instanceof DocumentFragment) {
var insertedNodes = Array.prototype.slice.apply(node.childNodes);
var _nativeResult = Native.Node_insertBefore.call(this, node, refNode);
// DocumentFragments can't be connected, so `disconnectTree` will never
// need to be called on a DocumentFragment's children after inserting it.
if (isConnected(this)) {
for (var i = 0; i < insertedNodes.length; i++) {
internals.connectTree(insertedNodes[i]);
}
}
return _nativeResult;
}
var nodeWasConnected = isConnected(node);
var nativeResult = Native.Node_insertBefore.call(this, node, refNode);
if (nodeWasConnected) {
internals.disconnectTree(node);
}
if (isConnected(this)) {
internals.connectTree(node);
}
return nativeResult;
});
setPropertyUnchecked(Node.prototype, 'appendChild',
/**
* @this {Node}
* @param {!Node} node
* @return {!Node}
*/
function (node) {
if (node instanceof DocumentFragment) {
var insertedNodes = Array.prototype.slice.apply(node.childNodes);
var _nativeResult2 = Native.Node_appendChild.call(this, node);
// DocumentFragments can't be connected, so `disconnectTree` will never
// need to be called on a DocumentFragment's children after inserting it.
if (isConnected(this)) {
for (var i = 0; i < insertedNodes.length; i++) {
internals.connectTree(insertedNodes[i]);
}
}
return _nativeResult2;
}
var nodeWasConnected = isConnected(node);
var nativeResult = Native.Node_appendChild.call(this, node);
if (nodeWasConnected) {
internals.disconnectTree(node);
}
if (isConnected(this)) {
internals.connectTree(node);
}
return nativeResult;
});
setPropertyUnchecked(Node.prototype, 'cloneNode',
/**
* @this {Node}
* @param {boolean=} deep
* @return {!Node}
*/
function (deep) {
var clone = Native.Node_cloneNode.call(this, deep);
// Only create custom elements if this element's owner document is
// associated with the registry.
if (!this.ownerDocument.__CE_hasRegistry) {
internals.patchTree(clone);
} else {
internals.patchAndUpgradeTree(clone);
}
return clone;
});
setPropertyUnchecked(Node.prototype, 'removeChild',
/**
* @this {Node}
* @param {!Node} node
* @return {!Node}
*/
function (node) {
var nodeWasConnected = isConnected(node);
var nativeResult = Native.Node_removeChild.call(this, node);
if (nodeWasConnected) {
internals.disconnectTree(node);
}
return nativeResult;
});
setPropertyUnchecked(Node.prototype, 'replaceChild',
/**
* @this {Node}
* @param {!Node} nodeToInsert
* @param {!Node} nodeToRemove
* @return {!Node}
*/
function (nodeToInsert, nodeToRemove) {
if (nodeToInsert instanceof DocumentFragment) {
var insertedNodes = Array.prototype.slice.apply(nodeToInsert.childNodes);
var _nativeResult3 = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove);
// DocumentFragments can't be connected, so `disconnectTree` will never
// need to be called on a DocumentFragment's children after inserting it.
if (isConnected(this)) {
internals.disconnectTree(nodeToRemove);
for (var i = 0; i < insertedNodes.length; i++) {
internals.connectTree(insertedNodes[i]);
}
}
return _nativeResult3;
}
var nodeToInsertWasConnected = isConnected(nodeToInsert);
var nativeResult = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove);
var thisIsConnected = isConnected(this);
if (thisIsConnected) {
internals.disconnectTree(nodeToRemove);
}
if (nodeToInsertWasConnected) {
internals.disconnectTree(nodeToInsert);
}
if (thisIsConnected) {
internals.connectTree(nodeToInsert);
}
return nativeResult;
});
function patch_textContent(destination, baseDescriptor) {
Object.defineProperty(destination, 'textContent', {
enumerable: baseDescriptor.enumerable,
configurable: true,
get: baseDescriptor.get,
set: /** @this {Node} */function set(assignedValue) {
// If this is a text node then there are no nodes to disconnect.
if (this.nodeType === Node.TEXT_NODE) {
baseDescriptor.set.call(this, assignedValue);
return;
}
var removedNodes = undefined;
// Checking for `firstChild` is faster than reading `childNodes.length`
// to compare with 0.
if (this.firstChild) {
// Using `childNodes` is faster than `children`, even though we only
// care about elements.
var childNodes = this.childNodes;
var childNodesLength = childNodes.length;
if (childNodesLength > 0 && isConnected(this)) {
// Copying an array by iterating is faster than using slice.
removedNodes = new Array(childNodesLength);
for (var i = 0; i < childNodesLength; i++) {
removedNodes[i] = childNodes[i];
}
}
}
baseDescriptor.set.call(this, assignedValue);
if (removedNodes) {
for (var _i = 0; _i < removedNodes.length; _i++) {
internals.disconnectTree(removedNodes[_i]);
}
}
}
});
}
if (Native.Node_textContent && Native.Node_textContent.get) {
patch_textContent(Node.prototype, Native.Node_textContent);
} else {
internals.addPatch(function (element) {
patch_textContent(element, {
enumerable: true,
configurable: true,
// NOTE: This implementation of the `textContent` getter assumes that
// text nodes' `textContent` getter will not be patched.
get: /** @this {Node} */function get() {
/** @type {!Array} */
var parts = [];
for (var i = 0; i < this.childNodes.length; i++) {
parts.push(this.childNodes[i].textContent);
}
return parts.join('');
},
set: /** @this {Node} */function set(assignedValue) {
while (this.firstChild) {
Native.Node_removeChild.call(this, this.firstChild);
}
Native.Node_appendChild.call(this, document.createTextNode(assignedValue));
}
});
});
}
};
/**
* @param {!CustomElementInternals} internals
* @param {!Object} destination
* @param {!ChildNodeNativeMethods} builtIn
*/
var PatchChildNode = function (internals, destination, builtIn) {
/**
* @param {...(!Node|string)} nodes
*/
destination['before'] = function () {
for (var _len = arguments.length, nodes = Array(_len), _key = 0; _key < _len; _key++) {
nodes[_key] = arguments[_key];
}
// TODO: Fix this for when one of `nodes` is a DocumentFragment!
var connectedBefore = /** @type {!Array} */nodes.filter(function (node) {
// DocumentFragments are not connected and will not be added to the list.
return node instanceof Node && isConnected(node);
});
builtIn.before.apply(this, nodes);
for (var i = 0; i < connectedBefore.length; i++) {
internals.disconnectTree(connectedBefore[i]);
}
if (isConnected(this)) {
for (var _i = 0; _i < nodes.length; _i++) {
var node = nodes[_i];
if (node instanceof Element) {
internals.connectTree(node);
}
}
}
};
/**
* @param {...(!Node|string)} nodes
*/
destination['after'] = function () {
for (var _len2 = arguments.length, nodes = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
nodes[_key2] = arguments[_key2];
}
// TODO: Fix this for when one of `nodes` is a DocumentFragment!
var connectedBefore = /** @type {!Array} */nodes.filter(function (node) {
// DocumentFragments are not connected and will not be added to the list.
return node instanceof Node && isConnected(node);
});
builtIn.after.apply(this, nodes);
for (var i = 0; i < connectedBefore.length; i++) {
internals.disconnectTree(connectedBefore[i]);
}
if (isConnected(this)) {
for (var _i2 = 0; _i2 < nodes.length; _i2++) {
var node = nodes[_i2];
if (node instanceof Element) {
internals.connectTree(node);
}
}
}
};
/**
* @param {...(!Node|string)} nodes
*/
destination['replaceWith'] = function () {
for (var _len3 = arguments.length, nodes = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
nodes[_key3] = arguments[_key3];
}
// TODO: Fix this for when one of `nodes` is a DocumentFragment!
var connectedBefore = /** @type {!Array} */nodes.filter(function (node) {
// DocumentFragments are not connected and will not be added to the list.
return node instanceof Node && isConnected(node);
});
var wasConnected = isConnected(this);
builtIn.replaceWith.apply(this, nodes);
for (var i = 0; i < connectedBefore.length; i++) {
internals.disconnectTree(connectedBefore[i]);
}
if (wasConnected) {
internals.disconnectTree(this);
for (var _i3 = 0; _i3 < nodes.length; _i3++) {
var node = nodes[_i3];
if (node instanceof Element) {
internals.connectTree(node);
}
}
}
};
destination['remove'] = function () {
var wasConnected = isConnected(this);
builtIn.remove.call(this);
if (wasConnected) {
internals.disconnectTree(this);
}
};
};
/**
* @param {!CustomElementInternals} internals
*/
var PatchElement = function (internals) {
if (Native.Element_attachShadow) {
setPropertyUnchecked(Element.prototype, 'attachShadow',
/**
* @this {Element}
* @param {!{mode: string}} init
* @return {ShadowRoot}
*/
function (init) {
var shadowRoot = Native.Element_attachShadow.call(this, init);
this.__CE_shadowRoot = shadowRoot;
return shadowRoot;
});
} else {
console.warn('Custom Elements: `Element#attachShadow` was not patched.');
}
function patch_innerHTML(destination, baseDescriptor) {
Object.defineProperty(destination, 'innerHTML', {
enumerable: baseDescriptor.enumerable,
configurable: true,
get: baseDescriptor.get,
set: /** @this {Element} */function set(htmlString) {
var _this = this;
var isConnected$$1 = isConnected(this);
// NOTE: In IE11, when using the native `innerHTML` setter, all nodes
// that were previously descendants of the context element have all of
// their children removed as part of the set - the entire subtree is
// 'disassembled'. This work around walks the subtree *before* using the
// native setter.
/** @type {!Array|undefined} */
var removedElements = undefined;
if (isConnected$$1) {
removedElements = [];
walkDeepDescendantElements(this, function (element) {
if (element !== _this) {
removedElements.push(element);
}
});
}
baseDescriptor.set.call(this, htmlString);
if (removedElements) {
for (var i = 0; i < removedElements.length; i++) {
var element = removedElements[i];
if (element.__CE_state === CustomElementState.custom) {
internals.disconnectedCallback(element);
}
}
}
// Only create custom elements if this element's owner document is
// associated with the registry.
if (!this.ownerDocument.__CE_hasRegistry) {
internals.patchTree(this);
} else {
internals.patchAndUpgradeTree(this);
}
return htmlString;
}
});
}
if (Native.Element_innerHTML && Native.Element_innerHTML.get) {
patch_innerHTML(Element.prototype, Native.Element_innerHTML);
} else if (Native.HTMLElement_innerHTML && Native.HTMLElement_innerHTML.get) {
patch_innerHTML(HTMLElement.prototype, Native.HTMLElement_innerHTML);
} else {
/** @type {HTMLDivElement} */
var rawDiv = Native.Document_createElement.call(document, 'div');
internals.addPatch(function (element) {
patch_innerHTML(element, {
enumerable: true,
configurable: true,
// Implements getting `innerHTML` by performing an unpatched `cloneNode`
// of the element and returning the resulting element's `innerHTML`.
// TODO: Is this too expensive?
get: /** @this {Element} */function get() {
return Native.Node_cloneNode.call(this, true).innerHTML;
},
// Implements setting `innerHTML` by creating an unpatched element,
// setting `innerHTML` of that element and replacing the target
// element's children with those of the unpatched element.
set: /** @this {Element} */function set(assignedValue) {
// NOTE: re-route to `content` for `template` elements.
// We need to do this because `template.appendChild` does not
// route into `template.content`.
/** @type {!Node} */
var content = this.localName === 'template' ? /** @type {!HTMLTemplateElement} */this.content : this;
rawDiv.innerHTML = assignedValue;
while (content.childNodes.length > 0) {
Native.Node_removeChild.call(content, content.childNodes[0]);
}
while (rawDiv.childNodes.length > 0) {
Native.Node_appendChild.call(content, rawDiv.childNodes[0]);
}
}
});
});
}
setPropertyUnchecked(Element.prototype, 'setAttribute',
/**
* @this {Element}
* @param {string} name
* @param {string} newValue
*/
function (name, newValue) {
// Fast path for non-custom elements.
if (this.__CE_state !== CustomElementState.custom) {
return Native.Element_setAttribute.call(this, name, newValue);
}
var oldValue = Native.Element_getAttribute.call(this, name);
Native.Element_setAttribute.call(this, name, newValue);
newValue = Native.Element_getAttribute.call(this, name);
internals.attributeChangedCallback(this, name, oldValue, newValue, null);
});
setPropertyUnchecked(Element.prototype, 'setAttributeNS',
/**
* @this {Element}
* @param {?string} namespace
* @param {string} name
* @param {string} newValue
*/
function (namespace, name, newValue) {
// Fast path for non-custom elements.
if (this.__CE_state !== CustomElementState.custom) {
return Native.Element_setAttributeNS.call(this, namespace, name, newValue);
}
var oldValue = Native.Element_getAttributeNS.call(this, namespace, name);
Native.Element_setAttributeNS.call(this, namespace, name, newValue);
newValue = Native.Element_getAttributeNS.call(this, namespace, name);
internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);
});
setPropertyUnchecked(Element.prototype, 'removeAttribute',
/**
* @this {Element}
* @param {string} name
*/
function (name) {
// Fast path for non-custom elements.
if (this.__CE_state !== CustomElementState.custom) {
return Native.Element_removeAttribute.call(this, name);
}
var oldValue = Native.Element_getAttribute.call(this, name);
Native.Element_removeAttribute.call(this, name);
if (oldValue !== null) {
internals.attributeChangedCallback(this, name, oldValue, null, null);
}
});
setPropertyUnchecked(Element.prototype, 'removeAttributeNS',
/**
* @this {Element}
* @param {?string} namespace
* @param {string} name
*/
function (namespace, name) {
// Fast path for non-custom elements.
if (this.__CE_state !== CustomElementState.custom) {
return Native.Element_removeAttributeNS.call(this, namespace, name);
}
var oldValue = Native.Element_getAttributeNS.call(this, namespace, name);
Native.Element_removeAttributeNS.call(this, namespace, name);
// In older browsers, `Element#getAttributeNS` may return the empty string
// instead of null if the attribute does not exist. For details, see;
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes
var newValue = Native.Element_getAttributeNS.call(this, namespace, name);
if (oldValue !== newValue) {
internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);
}
});
function patch_insertAdjacentElement(destination, baseMethod) {
setPropertyUnchecked(destination, 'insertAdjacentElement',
/**
* @this {Element}
* @param {string} where
* @param {!Element} element
* @return {?Element}
*/
function (where, element) {
var wasConnected = isConnected(element);
var insertedElement = /** @type {!Element} */
baseMethod.call(this, where, element);
if (wasConnected) {
internals.disconnectTree(element);
}
if (isConnected(insertedElement)) {
internals.connectTree(element);
}
return insertedElement;
});
}
if (Native.HTMLElement_insertAdjacentElement) {
patch_insertAdjacentElement(HTMLElement.prototype, Native.HTMLElement_insertAdjacentElement);
} else if (Native.Element_insertAdjacentElement) {
patch_insertAdjacentElement(Element.prototype, Native.Element_insertAdjacentElement);
} else {
console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');
}
PatchParentNode(internals, Element.prototype, {
prepend: Native.Element_prepend,
append: Native.Element_append
});
PatchChildNode(internals, Element.prototype, {
before: Native.Element_before,
after: Native.Element_after,
replaceWith: Native.Element_replaceWith,
remove: Native.Element_remove
});
};
/**
* @license
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
var priorCustomElements = window['customElements'];
if (!priorCustomElements || priorCustomElements['forcePolyfill'] || typeof priorCustomElements['define'] != 'function' || typeof priorCustomElements['get'] != 'function') {
/** @type {!CustomElementInternals} */
var internals = new CustomElementInternals();
PatchHTMLElement(internals);
PatchDocument(internals);
PatchNode(internals);
PatchElement(internals);
// The main document is always associated with the registry.
document.__CE_hasRegistry = true;
/** @type {!CustomElementRegistry} */
var customElements$1 = new CustomElementRegistry(internals);
Object.defineProperty(window, 'customElements', {
configurable: true,
enumerable: true,
value: customElements$1
});
}
/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.22
(function (global) {
if (global.JsMutationObserver) {
return;
}
var registrationsTable = new WeakMap();
var setImmediate;
if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout;
} else if (window.setImmediate) {
setImmediate = window.setImmediate;
} else {
var setImmediateQueue = [];
var sentinel = String(Math.random());
window.addEventListener("message", function (e) {
if (e.data === sentinel) {
var queue = setImmediateQueue;
setImmediateQueue = [];
queue.forEach(function (func) {
func();
});
}
});
setImmediate = function setImmediate(func) {
setImmediateQueue.push(func);
window.postMessage(sentinel, "*");
};
}
var isScheduled = false;
var scheduledObservers = [];
function scheduleCallback(observer) {
scheduledObservers.push(observer);
if (!isScheduled) {
isScheduled = true;
setImmediate(dispatchCallbacks);
}
}
function wrapIfNeeded(node) {
return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
}
function dispatchCallbacks() {
isScheduled = false;
var observers = scheduledObservers;
scheduledObservers = [];
observers.sort(function (o1, o2) {
return o1.uid_ - o2.uid_;
});
var anyNonEmpty = false;
observers.forEach(function (observer) {
var queue = observer.takeRecords();
removeTransientObserversFor(observer);
if (queue.length) {
observer.callback_(queue, observer);
anyNonEmpty = true;
}
});
if (anyNonEmpty) dispatchCallbacks();
}
function removeTransientObserversFor(observer) {
observer.nodes_.forEach(function (node) {
var registrations = registrationsTable.get(node);
if (!registrations) return;
registrations.forEach(function (registration) {
if (registration.observer === observer) registration.removeTransientObservers();
});
});
}
function forEachAncestorAndObserverEnqueueRecord(target, callback) {
for (var node = target; node; node = node.parentNode) {
var registrations = registrationsTable.get(node);
if (registrations) {
for (var j = 0; j < registrations.length; j++) {
var registration = registrations[j];
var options = registration.options;
if (node !== target && !options.subtree) continue;
var record = callback(options);
if (record) registration.enqueue(record);
}
}
}
}
var uidCounter = 0;
function JsMutationObserver(callback) {
this.callback_ = callback;
this.nodes_ = [];
this.records_ = [];
this.uid_ = ++uidCounter;
}
JsMutationObserver.prototype = {
observe: function observe(target, options) {
target = wrapIfNeeded(target);
if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
throw new SyntaxError();
}
var registrations = registrationsTable.get(target);
if (!registrations) registrationsTable.set(target, registrations = []);
var registration;
for (var i = 0; i < registrations.length; i++) {
if (registrations[i].observer === this) {
registration = registrations[i];
registration.removeListeners();
registration.options = options;
break;
}
}
if (!registration) {
registration = new Registration(this, target, options);
registrations.push(registration);
this.nodes_.push(target);
}
registration.addListeners();
},
disconnect: function disconnect() {
this.nodes_.forEach(function (node) {
var registrations = registrationsTable.get(node);
for (var i = 0; i < registrations.length; i++) {
var registration = registrations[i];
if (registration.observer === this) {
registration.removeListeners();
registrations.splice(i, 1);
break;
}
}
}, this);
this.records_ = [];
},
takeRecords: function takeRecords() {
var copyOfRecords = this.records_;
this.records_ = [];
return copyOfRecords;
}
};
function MutationRecord(type, target) {
this.type = type;
this.target = target;
this.addedNodes = [];
this.removedNodes = [];
this.previousSibling = null;
this.nextSibling = null;
this.attributeName = null;
this.attributeNamespace = null;
this.oldValue = null;
}
function copyMutationRecord(original) {
var record = new MutationRecord(original.type, original.target);
record.addedNodes = original.addedNodes.slice();
record.removedNodes = original.removedNodes.slice();
record.previousSibling = original.previousSibling;
record.nextSibling = original.nextSibling;
record.attributeName = original.attributeName;
record.attributeNamespace = original.attributeNamespace;
record.oldValue = original.oldValue;
return record;
}
var currentRecord, recordWithOldValue;
function getRecord(type, target) {
return currentRecord = new MutationRecord(type, target);
}
function getRecordWithOldValue(oldValue) {
if (recordWithOldValue) return recordWithOldValue;
recordWithOldValue = copyMutationRecord(currentRecord);
recordWithOldValue.oldValue = oldValue;
return recordWithOldValue;
}
function clearRecords() {
currentRecord = recordWithOldValue = undefined;
}
function recordRepresentsCurrentMutation(record) {
return record === recordWithOldValue || record === currentRecord;
}
function selectRecord(lastRecord, newRecord) {
if (lastRecord === newRecord) return lastRecord;
if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
return null;
}
function Registration(observer, target, options) {
this.observer = observer;
this.target = target;
this.options = options;
this.transientObservedNodes = [];
}
Registration.prototype = {
enqueue: function enqueue(record) {
var records = this.observer.records_;
var length = records.length;
if (records.length > 0) {
var lastRecord = records[length - 1];
var recordToReplaceLast = selectRecord(lastRecord, record);
if (recordToReplaceLast) {
records[length - 1] = recordToReplaceLast;
return;
}
} else {
scheduleCallback(this.observer);
}
records[length] = record;
},
addListeners: function addListeners() {
this.addListeners_(this.target);
},
addListeners_: function addListeners_(node) {
var options = this.options;
if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
},
removeListeners: function removeListeners() {
this.removeListeners_(this.target);
},
removeListeners_: function removeListeners_(node) {
var options = this.options;
if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
},
addTransientObserver: function addTransientObserver(node) {
if (node === this.target) return;
this.addListeners_(node);
this.transientObservedNodes.push(node);
var registrations = registrationsTable.get(node);
if (!registrations) registrationsTable.set(node, registrations = []);
registrations.push(this);
},
removeTransientObservers: function removeTransientObservers() {
var transientObservedNodes = this.transientObservedNodes;
this.transientObservedNodes = [];
transientObservedNodes.forEach(function (node) {
this.removeListeners_(node);
var registrations = registrationsTable.get(node);
for (var i = 0; i < registrations.length; i++) {
if (registrations[i] === this) {
registrations.splice(i, 1);
break;
}
}
}, this);
},
handleEvent: function handleEvent(e) {
e.stopImmediatePropagation();
switch (e.type) {
case "DOMAttrModified":
var name = e.attrName;
var namespace = e.relatedNode.namespaceURI;
var target = e.target;
var record = new getRecord("attributes", target);
record.attributeName = name;
record.attributeNamespace = namespace;
var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function (options) {
if (!options.attributes) return;
if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
return;
}
if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
return record;
});
break;
case "DOMCharacterDataModified":
var target = e.target;
var record = getRecord("characterData", target);
var oldValue = e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function (options) {
if (!options.characterData) return;
if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
return record;
});
break;
case "DOMNodeRemoved":
this.addTransientObserver(e.target);
case "DOMNodeInserted":
var changedNode = e.target;
var addedNodes, removedNodes;
if (e.type === "DOMNodeInserted") {
addedNodes = [changedNode];
removedNodes = [];
} else {
addedNodes = [];
removedNodes = [changedNode];
}
var previousSibling = changedNode.previousSibling;
var nextSibling = changedNode.nextSibling;
var record = getRecord("childList", e.target.parentNode);
record.addedNodes = addedNodes;
record.removedNodes = removedNodes;
record.previousSibling = previousSibling;
record.nextSibling = nextSibling;
forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function (options) {
if (!options.childList) return;
return record;
});
}
clearRecords();
}
};
global.JsMutationObserver = JsMutationObserver;
if (!global.MutationObserver) {
global.MutationObserver = JsMutationObserver;
JsMutationObserver._isPolyfilled = true;
}
})(self);
/*
Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
(function (global, undefined) {
if (global.setImmediate) {
return;
}
var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};
var currentlyRunningATask = false;
var doc = global.document;
var setImmediate;
function addFromSetImmediateArguments(args) {
tasksByHandle[nextHandle] = partiallyApplied.apply(undefined, args);
return nextHandle++;
}
// This function accepts the same arguments as setImmediate, but
// returns a function that requires no arguments.
function partiallyApplied(handler) {
var args = [].slice.call(arguments, 1);
return function () {
if (typeof handler === "function") {
handler.apply(undefined, args);
} else {
new Function("" + handler)();
}
};
}
function runIfPresent(handle) {
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
// So if we're currently running a task, we'll need to delay this invocation.
if (currentlyRunningATask) {
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// "too much recursion" error.
setTimeout(partiallyApplied(runIfPresent, handle), 0);
} else {
var task = tasksByHandle[handle];
if (task) {
currentlyRunningATask = true;
try {
task();
} finally {
clearImmediate(handle);
currentlyRunningATask = false;
}
}
}
}
function clearImmediate(handle) {
delete tasksByHandle[handle];
}
function installNextTickImplementation() {
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
process.nextTick(partiallyApplied(runIfPresent, handle));
return handle;
};
}
function canUsePostMessage() {
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
// where `global.postMessage` means something completely different and can't be used for this purpose.
if (global.postMessage && !global.importScripts) {
var postMessageIsAsynchronous = true;
var oldOnMessage = global.onmessage;
global.onmessage = function () {
postMessageIsAsynchronous = false;
};
global.postMessage("", "*");
global.onmessage = oldOnMessage;
return postMessageIsAsynchronous;
}
}
function installPostMessageImplementation() {
// Installs an event handler on `global` for the `message` event: see
// * https://developer.mozilla.org/en/DOM/window.postMessage
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
var messagePrefix = "setImmediate$" + Math.random() + "$";
var onGlobalMessage = function onGlobalMessage(event) {
if (event.source === global && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) {
runIfPresent(+event.data.slice(messagePrefix.length));
}
};
if (global.addEventListener) {
global.addEventListener("message", onGlobalMessage, false);
} else {
global.attachEvent("onmessage", onGlobalMessage);
}
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
global.postMessage(messagePrefix + handle, "*");
return handle;
};
}
function installMessageChannelImplementation() {
var channel = new MessageChannel();
channel.port1.onmessage = function (event) {
var handle = event.data;
runIfPresent(handle);
};
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
channel.port2.postMessage(handle);
return handle;
};
}
function installReadyStateChangeImplementation() {
var html = doc.documentElement;
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
// Create a
*/
var ActionSheetElement = function (_BaseDialogElement) {
inherits(ActionSheetElement, _BaseDialogElement);
/**
* @event preshow
* @description
* [en]Fired just before the action sheet is displayed.[/en]
* [ja]ダイアログが表示される直前に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.actionSheet
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Execute this function to stop the action sheet from being shown.[/en]
* [ja]この関数を実行すると、ダイアログの表示がキャンセルされます。[/ja]
*/
/**
* @event postshow
* @description
* [en]Fired just after the action sheet is displayed.[/en]
* [ja]ダイアログが表示された直後に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.actionSheet
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @event prehide
* @description
* [en]Fired just before the action sheet is hidden.[/en]
* [ja]ダイアログが隠れる直前に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.actionSheet
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Execute this function to stop the action sheet from being hidden.[/en]
* [ja]この関数を実行すると、ダイアログの非表示がキャンセルされます。[/ja]
*/
/**
* @event posthide
* @description
* [en]Fired just after the action sheet is hidden.[/en]
* [ja]ダイアログが隠れた後に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.actionSheet
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @attribute title
* @type {String}
* @description
* [en]Optional title of the action sheet. A new element will be created containing this string.[/en]
* [ja]アクションシートのタイトルを指定します。ここで指定した文字列を含む新しい要素が作成されます。[/ja]
*/
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the action sheet.[/en]
* [ja]ダイアログの表現を指定します。[/ja]
*/
/**
* @attribute cancelable
* @description
* [en]If this attribute is set the action sheet can be closed by tapping the background or by pressing the back button on Android devices.[/en]
* [ja]この属性が設定されると、アクションシートの背景やAndroidデバイスのバックボタンを推すことでアクションシートが閉じるようになります。[/ja]
*/
/**
* @attribute disabled
* @description
* [en]If this attribute is set the action sheet is disabled.[/en]
* [ja]この属性がある時、ダイアログはdisabled状態になります。[/ja]
*/
/**
* @attribute animation
* @type {String}
* @default default
* @description
* [en]The animation used when showing and hiding the action sheet. Can be either `"none"` or `"default"`.[/en]
* [ja]ダイアログを表示する際のアニメーション名を指定します。"none"もしくは"default"を指定できます。[/ja]
*/
/**
* @attribute animation-options
* @type {Expression}
* @description
* [en]Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。e.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`[/ja]
*/
/**
* @attribute mask-color
* @type {String}
* @default rgba(0, 0, 0, 0.2)
* @description
* [en]Color of the background mask. Default is `"rgba(0, 0, 0, 0.2)"`.[/en]
* [ja]背景のマスクの色を指定します。"rgba(0, 0, 0, 0.2)"がデフォルト値です。[/ja]
*/
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;
/* Expected result:
*
*
*
*
');
icon.classList.add(this._defaultClassName.replace('button', 'icon'));
this.insertBefore(icon, this.firstChild);
}
this._updateRipple();
ModifierUtil.initModifier(this, this._scheme);
}
}, {
key: '_updateIcon',
value: function _updateIcon() {
if (this._icon) {
this._icon.setAttribute('icon', this.getAttribute('icon'));
}
}
}, {
key: '_updateRipple',
value: function _updateRipple() {
this._rippleOpt && util$1.updateRipple.apply(util$1, toConsumableArray(this._rippleOpt));
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, this._defaultClassName, this._scheme);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, this._scheme);
break;
case 'icon':
this._updateIcon();
break;
case 'ripple':
this.classList.contains(this._defaultClassName) && this._updateRipple();
break;
}
}
}, {
key: 'disabled',
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'disabled', value);
},
get: function get$$1() {
return this.hasAttribute('disabled');
}
}, {
key: '_icon',
get: function get$$1() {
return util$1.findChild(this, 'ons-icon');
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class', 'icon', 'ripple'];
}
}]);
return BaseButtonElement;
}(BaseElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-action-sheet-button
* @category dialog
* @modifier destructive
* [en]Shows a "destructive" button (only for iOS).[/en]
* [ja]"destructive"なボタンを表示します(iOSでのみ有効)。[/ja]
* @description
* [en]Component that represent each button of the action sheet.[/en]
* [ja]アクションシートに表示される各ボタンを表現するコンポーネントです。[/ja]
* @seealso ons-action-sheet
* [en]The `` component[/en]
* [ja]ons-action-sheetコンポーネント[/ja]
* @seealso ons-list-item
* [en]The `` component[/en]
* [ja]ons-list-itemコンポーネント[/ja]
* @seealso ons-icon
* [en]The `` component[/en]
* [ja]ons-iconコンポーネント[/ja]
* @tutorial vanilla/Reference/action-sheet
* @guide appsize.html#removing-icon-packs [en]Removing icon packs.[/en][ja][/ja]
* @guide faq.html#how-can-i-use-custom-icon-packs [en]Adding custom icon packs.[/en][ja][/ja]
* @modifier material
* [en]Display a Material Design action sheet button.[/en]
* [ja]マテリアルデザインのアクションシート用のボタンを表示します。[/ja]
* @example
*
* Label
* Label
*
*
*
*/
var ActionSheetButtonElement = function (_BaseButtonElement) {
inherits(ActionSheetButtonElement, _BaseButtonElement);
function ActionSheetButtonElement() {
classCallCheck(this, ActionSheetButtonElement);
return possibleConstructorReturn(this, (ActionSheetButtonElement.__proto__ || Object.getPrototypeOf(ActionSheetButtonElement)).apply(this, arguments));
}
createClass(ActionSheetButtonElement, [{
key: '_scheme',
/**
* @attribute icon
* @type {String}
* @description
* [en]Creates an `ons-icon` component with this string. Only visible on Android. Check [See also](#seealso) section for more information.[/en]
* [ja]`ons-icon`コンポーネントを悪性します。Androidでのみ表示されます。[/ja]
*/
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the action sheet button.[/en]
* [ja]アクションシートボタンの見た目を設定します。[/ja]
*/
get: function get$$1() {
return {
'': 'action-sheet-button--*',
'.action-sheet-icon': 'action-sheet-icon--*'
};
}
}, {
key: '_defaultClassName',
get: function get$$1() {
return 'action-sheet-button';
}
}, {
key: '_rippleOpt',
get: function get$$1() {
return undefined;
}
}]);
return ActionSheetButtonElement;
}(BaseButtonElement);
onsElements.ActionSheetButton = ActionSheetButtonElement;
customElements.define('ons-action-sheet-button', ActionSheetButtonElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var AlertDialogAnimator = function (_BaseAnimator) {
inherits(AlertDialogAnimator, _BaseAnimator);
function AlertDialogAnimator() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$timing = _ref.timing,
timing = _ref$timing === undefined ? 'linear' : _ref$timing,
_ref$delay = _ref.delay,
delay = _ref$delay === undefined ? 0 : _ref$delay,
_ref$duration = _ref.duration,
duration = _ref$duration === undefined ? 0.2 : _ref$duration;
classCallCheck(this, AlertDialogAnimator);
return possibleConstructorReturn(this, (AlertDialogAnimator.__proto__ || Object.getPrototypeOf(AlertDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
}
/**
* @param {HTMLElement} dialog
* @param {Function} done
*/
createClass(AlertDialogAnimator, [{
key: 'show',
value: function show(dialog, done) {
done();
}
/**
* @param {HTMLElement} dialog
* @param {Function} done
*/
}, {
key: 'hide',
value: function hide(dialog, done) {
done();
}
}]);
return AlertDialogAnimator;
}(BaseAnimator);
/**
* Android style animator for alert dialog.
*/
var AndroidAlertDialogAnimator = function (_AlertDialogAnimator) {
inherits(AndroidAlertDialogAnimator, _AlertDialogAnimator);
function AndroidAlertDialogAnimator() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref2$timing = _ref2.timing,
timing = _ref2$timing === undefined ? 'cubic-bezier(.1, .7, .4, 1)' : _ref2$timing,
_ref2$duration = _ref2.duration,
duration = _ref2$duration === undefined ? 0.2 : _ref2$duration,
_ref2$delay = _ref2.delay,
delay = _ref2$delay === undefined ? 0 : _ref2$delay;
classCallCheck(this, AndroidAlertDialogAnimator);
return possibleConstructorReturn(this, (AndroidAlertDialogAnimator.__proto__ || Object.getPrototypeOf(AndroidAlertDialogAnimator)).call(this, { duration: duration, timing: timing, delay: delay }));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
createClass(AndroidAlertDialogAnimator, [{
key: 'show',
value: function show(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0) scale3d(.9, .9, 1)', opacity: 0 }, { transform: 'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)', opacity: 1 }).queue(function (done) {
callback();
done();
}));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
}, {
key: 'hide',
value: function hide(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)', opacity: 1 }, { transform: 'translate3d(-50%, -50%, 0) scale3d(.9, .9, 1)', opacity: 0 }).queue(function (done) {
callback();
done();
}));
}
}]);
return AndroidAlertDialogAnimator;
}(AlertDialogAnimator);
/**
* iOS style animator for alert dialog.
*/
var IOSAlertDialogAnimator = function (_AlertDialogAnimator2) {
inherits(IOSAlertDialogAnimator, _AlertDialogAnimator2);
function IOSAlertDialogAnimator() {
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref3$timing = _ref3.timing,
timing = _ref3$timing === undefined ? 'cubic-bezier(.1, .7, .4, 1)' : _ref3$timing,
_ref3$duration = _ref3.duration,
duration = _ref3$duration === undefined ? 0.2 : _ref3$duration,
_ref3$delay = _ref3.delay,
delay = _ref3$delay === undefined ? 0 : _ref3$delay;
classCallCheck(this, IOSAlertDialogAnimator);
return possibleConstructorReturn(this, (IOSAlertDialogAnimator.__proto__ || Object.getPrototypeOf(IOSAlertDialogAnimator)).call(this, { duration: duration, timing: timing, delay: delay }));
}
/*
* @param {Object} dialog
* @param {Function} callback
*/
createClass(IOSAlertDialogAnimator, [{
key: 'show',
value: function show(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0) scale3d(1.3, 1.3, 1)', opacity: 0 }, { transform: 'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)', opacity: 1 }).queue(function (done) {
callback();
done();
}));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
}, {
key: 'hide',
value: function hide(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), Animit(dialog._dialog, this.def).default({ opacity: 1 }, { opacity: 0 }).queue(function (done) {
callback();
done();
}));
}
}]);
return IOSAlertDialogAnimator;
}(AlertDialogAnimator);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var scheme$1 = {
'.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$1 = {
'none': AlertDialogAnimator,
'default': function _default() {
return platform.isAndroid() ? AndroidAlertDialogAnimator : IOSAlertDialogAnimator;
},
'fade': function fade() {
return platform.isAndroid() ? AndroidAlertDialogAnimator : IOSAlertDialogAnimator;
}
};
/**
* @element ons-alert-dialog
* @category dialog
* @description
* [en]
* Alert dialog that is displayed on top of the current screen. Useful for displaying questions, warnings or error messages to the user. The title, content and buttons can be easily customized and it will automatically switch style based on the platform.
*
* To use the element it can either be attached directly to the `` element or dynamically created from a template using the `ons.createAlertDialog(template)` utility function and the `` tag.
* [/en]
* [ja]
* 現在のスクリーンの上に表示するアラートダイアログです。ユーザに対する問いかけ、警告、エラーメッセージを表示するのに利用できます。タイトルやコンテンツやボタンは簡単にカスタマイズでき、実行しているプラットフォームに併せてスタイルが自動的に切り替わります。
* [/ja]
* @codepen Qwwxyp
* @tutorial vanilla/Reference/alert-dialog
* @modifier material
* [en]Material Design style[/en]
* [ja]マテリアルデザインのスタイル[/ja]
* @modifier rowfooter
* [en]Horizontally aligns the footer buttons.[/en]
* [ja]フッターの複数のボタンを水平に配置[/ja]
* @seealso ons-dialog
* [en]ons-dialog component[/en]
* [ja]ons-dialogコンポーネント[/ja]
* @seealso ons-popover
* [en]ons-popover component[/en]
* [ja]ons-dialogコンポーネント[/ja]
* @seealso ons.notification
* [en]Using ons.notification utility functions.[/en]
* [ja]アラートダイアログを表示するには、ons.notificationオブジェクトのメソッドを使うこともできます。[/ja]
* @example
*
*
Warning!
*
* An error has occurred!
*
*
*
*
*/
var AlertDialogElement = function (_BaseDialogElement) {
inherits(AlertDialogElement, _BaseDialogElement);
/**
* @event preshow
* @description
* [en]Fired just before the alert dialog is displayed.[/en]
* [ja]アラートダイアログが表示される直前に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.alertDialog
* [en]Alert dialog object.[/en]
* [ja]アラートダイアログのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Execute to stop the dialog from showing.[/en]
* [ja]この関数を実行すると、アラートダイアログの表示を止めます。[/ja]
*/
/**
* @event postshow
* @description
* [en]Fired just after the alert dialog is displayed.[/en]
* [ja]アラートダイアログが表示された直後に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.alertDialog
* [en]Alert dialog object.[/en]
* [ja]アラートダイアログのオブジェクト。[/ja]
*/
/**
* @event prehide
* @description
* [en]Fired just before the alert dialog is hidden.[/en]
* [ja]アラートダイアログが隠れる直前に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.alertDialog
* [en]Alert dialog object.[/en]
* [ja]アラートダイアログのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Execute to stop the dialog from hiding.[/en]
* [ja]この関数を実行すると、アラートダイアログが閉じようとするのを止めます。[/ja]
*/
/**
* @event posthide
* @description
* [en]Fired just after the alert dialog is hidden.[/en]
* [ja]アラートダイアログが隠れた後に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.alertDialog
* [en]Alert dialog object.[/en]
* [ja]アラートダイアログのオブジェクト。[/ja]
*/
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the dialog.[/en]
* [ja]ダイアログの見た目を指定します。[/ja]
*/
/**
* @attribute cancelable
* @description
* [en]If this attribute is set the dialog can be closed by tapping the background or by pressing the back button on Android devices.[/en]
* [ja]この属性を設定すると、ダイアログの背景をタップしたりAndroidデバイスのバックボタンを押すとダイアログが閉じるようになります。[/ja]
*/
/**
* @attribute disabled
* @description
* [en]If this attribute is set the dialog is disabled.[/en]
* [ja]この属性がある時、アラートダイアログはdisabled状態になります。[/ja]
*/
/**
* @attribute animation
* @type {String}
* @default default
* @description
* [en]The animation used when showing and hiding the dialog. Can be either `"none"` or `"default"`.[/en]
* [ja]ダイアログを表示する際のアニメーション名を指定します。デフォルトでは"none"か"default"が指定できます。[/ja]
*/
/**
* @attribute animation-options
* @type {Expression}
* @description
* [en]Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。例:{duration: 0.2, delay: 1, timing: 'ease-in'}[/ja]
*/
/**
* @attribute mask-color
* @type {String}
* @default rgba(0, 0, 0, 0.2)
* @description
* [en]Color of the background mask. Default is "rgba(0, 0, 0, 0.2)".[/en]
* [ja]背景のマスクの色を指定します。"rgba(0, 0, 0, 0.2)"がデフォルト値です。[/ja]
*/
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$1,
baseClass: AlertDialogAnimator,
baseClassName: 'AlertDialogAnimator',
defaultAnimation: this.getAttribute('animation')
});
}
}, {
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.style.display = 'none';
this.style.zIndex = 10001;
/**
* Expected result after compile:
*
*
*
*
*
...
*
*
*/
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$1.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);
}
/**
* @property disabled
* @type {Boolean}
* @description
* [en]Whether the element is disabled or not.[/en]
* [ja]無効化されている場合に`true`。[/ja]
*/
/**
* @property cancelable
* @type {Boolean}
* @description
* [en]Whether the dialog is cancelable or not. A cancelable dialog can be closed by tapping the background or by pressing the back button on Android devices.[/en]
* [ja]そのダイアログがキャンセル可能かどうかを表します。キャンセル可能なダイアログは、背景をタップするかAndroidデバイスのバックボタンを押すことで閉じることが出来るようになります。[/ja]
*/
/**
* @method show
* @signature show([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクトです。[/ja]
* @param {String} [options.animation]
* [en]Animation name. Available animations are `"fade"` and `"none"`.[/en]
* [ja]アニメーション名を指定します。指定できるのは、"fade", "none"のいずれかです。[/ja]
* @param {String} [options.animationOptions]
* [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, delay, timingを指定します。e.g. {duration: 0.2, delay: 0.4, timing: 'ease-in'} [/ja]
* @param {Function} [options.callback]
* [en]Function to execute after the dialog has been revealed.[/en]
* [ja]ダイアログが表示され終わった時に呼び出されるコールバックを指定します。[/ja]
* @description
* [en]Show the alert dialog.[/en]
* [ja]ダイアログを表示します。[/ja]
* @return {Promise}
* [en]A `Promise` object that resolves to the displayed element.[/en]
* [ja]表示される要素を解決する`Promise`オブジェクトを返します。[/ja]
*/
/**
* @method hide
* @signature hide([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {String} [options.animation]
* [en]Animation name. Available animations are `"fade"` and `"none"`.[/en]
* [ja]アニメーション名を指定します。"fade", "none"のいずれかを指定します。[/ja]
* @param {String} [options.animationOptions]
* [en]Specify the animation's duration, delay and timing. E.g. {duration: 0.2, delay: 0.4, timing: 'ease-in'}[/en]
* [ja]アニメーション時のduration, delay, timingを指定します。e.g. {duration: 0.2, delay: 0.4, timing: 'ease-in'} [/ja]
* @param {Function} [options.callback]
* [en]Function to execute after the dialog has been hidden.[/en]
* [ja]このダイアログが閉じた時に呼び出されるコールバックを指定します。[/ja]
* @description
* [en]Hide the alert dialog.[/en]
* [ja]ダイアログを閉じます。[/ja]
* @return {Promise}
* [en]Resolves to the hidden element[/en]
* [ja]隠れた要素を解決する`Promise`オブジェクトを返します。[/ja]
*/
/**
* @property visible
* @readonly
* @type {Boolean}
* @description
* [en]Whether the dialog is visible or not.[/en]
* [ja]要素が見える場合に`true`。[/ja]
*/
/**
* @property onDeviceBackButton
* @type {Object}
* @description
* [en]Back-button handler.[/en]
* [ja]バックボタンハンドラ。[/ja]
*/
/**
* @param {String} name
* @param {DialogAnimator} Animator
*/
}, {
key: '_scheme',
get: function get$$1() {
return scheme$1;
}
/**
* @return {Element}
*/
}, {
key: '_mask',
get: function get$$1() {
return util$1.findChild(this, '.alert-dialog-mask');
}
/**
* @return {Element}
*/
}, {
key: '_dialog',
get: function get$$1() {
return util$1.findChild(this, '.alert-dialog');
}
/**
* @return {Element}
*/
}, {
key: '_titleElement',
get: function get$$1() {
return util$1.findChild(this._dialog.children[0], '.alert-dialog-title');
}
/**
* @return {Element}
*/
}, {
key: '_contentElement',
get: function get$$1() {
return util$1.findChild(this._dialog.children[0], '.alert-dialog-content');
}
}], [{
key: 'registerAnimator',
value: function registerAnimator(name, Animator) {
if (!(Animator.prototype instanceof AlertDialogAnimator)) {
util$1.throwAnimator('AlertDialog');
}
_animatorDict$1[name] = Animator;
}
}, {
key: 'animators',
get: function get$$1() {
return _animatorDict$1;
}
}, {
key: 'AlertDialogAnimator',
get: function get$$1() {
return AlertDialogAnimator;
}
}]);
return AlertDialogElement;
}(BaseDialogElement);
onsElements.AlertDialog = AlertDialogElement;
customElements.define('ons-alert-dialog', AlertDialogElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-alert-dialog-button
* @modifier material
* [en]Material Design alert-dialog button.[/en]
* [ja]マテリアルデザインのボタンを表示します。[/ja]
* @description
* [en][/en]
* [ja][/ja]
* @seealso ons-alert-dialog
* [en]The `` component displays a alert dialog.[/en]
* [ja]ons-alert-dialogコンポーネント[/ja]
* @example
*
*
Warning!
*
* An error has occurred!
*
*
*
*/
var AlertDialogButtonElement = function (_BaseButtonElement) {
inherits(AlertDialogButtonElement, _BaseButtonElement);
function AlertDialogButtonElement() {
classCallCheck(this, AlertDialogButtonElement);
return possibleConstructorReturn(this, (AlertDialogButtonElement.__proto__ || Object.getPrototypeOf(AlertDialogButtonElement)).apply(this, arguments));
}
createClass(AlertDialogButtonElement, [{
key: '_scheme',
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the button.[/en]
* [ja]ボタンの表現を指定します。[/ja]
*/
/**
* @attribute disabled
* @description
* [en]Specify if button should be disabled.[/en]
* [ja]ボタンを無効化する場合は指定してください。[/ja]
*/
/**
* @property disabled
* @type {Boolean}
* @description
* [en]Whether the element is disabled or not.[/en]
* [ja]無効化されている場合に`true`。[/ja]
*/
get: function get$$1() {
return { '': 'alert-dialog-button--*' };
}
}, {
key: '_defaultClassName',
get: function get$$1() {
return 'alert-dialog-button';
}
}, {
key: '_rippleOpt',
get: function get$$1() {
return [this, undefined, { 'modifier': 'light-gray' }];
}
}]);
return AlertDialogButtonElement;
}(BaseButtonElement);
onsElements.AlertDialogButton = AlertDialogButtonElement;
customElements.define('ons-alert-dialog-button', AlertDialogButtonElement);
var iosBackButtonIcon = "\n\n";
var mdBackButtonIcon = "\n\n";
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName = 'back-button';
var scheme$2 = {
'': 'back-button--*',
'.back-button__icon': 'back-button--*__icon',
'.back-button__label': 'back-button--*__label'
};
/**
* @element ons-back-button
* @category navigation
* @description
* [en]
* Back button component for ``. Put it in the left part of the ``.
*
* It will find the parent `` element and pop a page when clicked. This behavior can be overriden by specifying the `onClick` property.
* [/en]
* [ja][/ja]
* @codepen aHmGL
* @tutorial vanilla/Reference/back-button
* @modifier material
* [en]Material Design style[/en]
* [ja][/ja]
* @seealso ons-toolbar
* [en]ons-toolbar component[/en]
* [ja]ons-toolbarコンポーネント[/ja]
* @seealso ons-navigator
* [en]ons-navigator component[/en]
* [ja]ons-navigatorコンポーネント[/ja]
* @example
*
*
* Back
*
*
* Title
*
*
*/
var BackButtonElement = function (_BaseElement) {
inherits(BackButtonElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the back button.[/en]
* [ja]バックボタンの見た目を指定します。[/ja]
*/
function BackButtonElement() {
classCallCheck(this, BackButtonElement);
var _this = possibleConstructorReturn(this, (BackButtonElement.__proto__ || Object.getPrototypeOf(BackButtonElement)).call(this));
contentReady(_this, function () {
_this._compile();
});
_this._options = {};
_this._boundOnClick = _this._onClick.bind(_this);
return _this;
}
createClass(BackButtonElement, [{
key: '_updateIcon',
value: function _updateIcon() {
var icon = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : util$1.findChild(this, '.back-button__icon');
icon.innerHTML = autoStyle.getPlatform(this) === 'android' || util$1.hasModifier(this, 'material') ? mdBackButtonIcon : iosBackButtonIcon;
}
}, {
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.classList.add(defaultClassName);
if (!util$1.findChild(this, '.back-button__label')) {
var label = util$1.create('span.back-button__label');
while (this.childNodes[0]) {
label.appendChild(this.childNodes[0]);
}
this.appendChild(label);
}
if (!util$1.findChild(this, '.back-button__icon')) {
var icon = util$1.create('span.back-button__icon');
this._updateIcon(icon);
this.insertBefore(icon, this.children[0]);
}
util$1.updateRipple(this, undefined, { center: '', 'size': 'contain', 'background': 'transparent' });
ModifierUtil.initModifier(this, scheme$2);
}
/**
* @property options
* @type {Object}
* @description
* [en]Options object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
*/
/**
* @property options.animation
* @type {String}
* @description
* [en]Animation name. Available animations are "slide", "lift", "fade" and "none".
* These are platform based animations. For fixed animations, add "-ios" or "-md"
* suffix to the animation name. E.g. "lift-ios", "lift-md". Defaults values are "slide-ios" and "fade-md".
* [/en]
* [ja][/ja]
*/
/**
* @property options.animationOptions
* @type {String}
* @description
* [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`[/en]
* [ja]アニメーション時のduration, delay, timingを指定します。e.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}` [/ja]
*/
/**
* @property options.callback
* @type {String}
* @description
* [en]Function that is called when the transition has ended.[/en]
* [ja]このメソッドによる画面遷移が終了した際に呼び出される関数オブジェクトを指定します。[/ja]
*/
}, {
key: '_onClick',
/**
* @property onClick
* @type {Function}
* @description
* [en]Used to override the default back button behavior.[/en]
* [ja][/ja]
*/
value: function _onClick() {
if (this.onClick) {
this.onClick.apply(this);
} else {
var navigator = util$1.findParent(this, 'ons-navigator');
if (navigator) {
navigator.popPage(this.options);
}
}
}
}, {
key: 'connectedCallback',
value: function connectedCallback() {
this.addEventListener('click', this._boundOnClick, false);
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName, scheme$2);
break;
case 'modifier':
{
ModifierUtil.onModifierChanged(last, current, this, scheme$2) && this._updateIcon();
break;
}
}
}
}, {
key: 'disconnectedCallback',
value: function disconnectedCallback() {
this.removeEventListener('click', this._boundOnClick, false);
}
}, {
key: 'show',
value: function show() {
this.style.display = 'inline-block';
}
}, {
key: 'hide',
value: function hide() {
this.style.display = 'none';
}
}, {
key: 'options',
get: function get$$1() {
return this._options;
},
set: function set$$1(object) {
this._options = object;
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class'];
}
}]);
return BackButtonElement;
}(BaseElement);
onsElements.BackButton = BackButtonElement;
customElements.define('ons-back-button', BackButtonElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$1 = 'bottom-bar';
var scheme$3 = { '': 'bottom-bar--*' };
/**
* @element ons-bottom-toolbar
* @category page
* @description
* [en]Toolbar component that is positioned at the bottom of the page. Since bottom toolbars are very versatile elements, `ons-bottom-toolbar` does not provide any specific layout syntax for its children. Modifiers or custom CSS must be used.[/en]
* [ja]ページ下部に配置されるツールバー用コンポーネントです。[/ja]
* @modifier transparent
* [en]Make the toolbar transparent.[/en]
* [ja]ツールバーの背景を透明にして表示します。[/ja]
* @modifier aligned
* [en]Vertically aligns its children and applies flexbox for block elements. `justify-content` CSS rule can be used to change horizontal align.[/en]
* [ja]ツールバーの背景を透明にして表示します。[/ja]
* @seealso ons-toolbar [en]ons-toolbar component[/en][ja]ons-toolbarコンポーネント[/ja]
* @example
*
* Content
*
*/
var BottomToolbarElement = function (_BaseElement) {
inherits(BottomToolbarElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the toolbar.[/en]
* [ja]ツールバーの見た目の表現を指定します。[/ja]
*/
function BottomToolbarElement() {
classCallCheck(this, BottomToolbarElement);
var _this = possibleConstructorReturn(this, (BottomToolbarElement.__proto__ || Object.getPrototypeOf(BottomToolbarElement)).call(this));
_this.classList.add(defaultClassName$1);
ModifierUtil.initModifier(_this, scheme$3);
return _this;
}
createClass(BottomToolbarElement, [{
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$1, scheme$3);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$3);
break;
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class'];
}
}]);
return BottomToolbarElement;
}(BaseElement);
onsElements.BottomToolbar = BottomToolbarElement;
customElements.define('ons-bottom-toolbar', BottomToolbarElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-button
* @category form
* @modifier outline
* [en]Button with outline and transparent background[/en]
* [ja]アウトラインを持ったボタンを表示します。[/ja]
* @modifier light
* [en]Button that doesn't stand out.[/en]
* [ja]目立たないボタンを表示します。[/ja]
* @modifier quiet
* [en]Button with no outline and or background..[/en]
* [ja]枠線や背景が無い文字だけのボタンを表示します。[/ja]
* @modifier cta
* [en]Button that really stands out.[/en]
* [ja]目立つボタンを表示します。[/ja]
* @modifier large
* [en]Large button that covers the width of the screen.[/en]
* [ja]横いっぱいに広がる大きなボタンを表示します。[/ja]
* @modifier large--quiet
* [en]Large quiet button.[/en]
* [ja]横いっぱいに広がるquietボタンを表示します。[/ja]
* @modifier large--cta
* [en]Large call to action button.[/en]
* [ja]横いっぱいに広がるctaボタンを表示します。[/ja]
* @modifier material
* [en]Material Design button[/en]
* [ja]マテリアルデザインのボタン[/ja]
* @modifier material--flat
* [en]Material Design flat button[/en]
* [ja]マテリアルデザインのフラットボタン[/ja]
* @description
* [en]
* Button component. If you want to place a button in a toolbar, use `` or `` instead.
*
* Will automatically display as a Material Design button with a ripple effect on Android.
* [/en]
* [ja]ボタン用コンポーネント。ツールバーにボタンを設置する場合は、ons-toolbar-buttonもしくはons-back-buttonコンポーネントを使用します。[/ja]
* @codepen hLayx
* @tutorial vanilla/Reference/button
* @guide theming.html#modifiers [en]More details about the `modifier` attribute[/en][ja]modifier属性の使い方[/ja]
* @guide theming.html#cross-platform-styling-autostyling [en]Information about cross platform styling[/en][ja]Information about cross platform styling[/ja]
* @example
*
* Tap Me
*
*/
var ButtonElement = function (_BaseButtonElement) {
inherits(ButtonElement, _BaseButtonElement);
function ButtonElement() {
classCallCheck(this, ButtonElement);
return possibleConstructorReturn(this, (ButtonElement.__proto__ || Object.getPrototypeOf(ButtonElement)).apply(this, arguments));
}
createClass(ButtonElement, [{
key: '_scheme',
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the button.[/en]
* [ja]ボタンの表現を指定します。[/ja]
*/
/**
* @attribute ripple
* @description
* [en]If this attribute is defined, the button will have a ripple effect.[/en]
* [ja][/ja]
*/
/**
* @attribute disabled
* @description
* [en]Specify if button should be disabled.[/en]
* [ja]ボタンを無効化する場合は指定します。[/ja]
*/
/**
* @property disabled
* @type {Boolean}
* @description
* [en]Whether the button is disabled or not.[/en]
* [ja]無効化されている場合に`true`。[/ja]
*/
get: function get$$1() {
return { '': 'button--*' };
}
}, {
key: '_defaultClassName',
get: function get$$1() {
return 'button';
}
}]);
return ButtonElement;
}(BaseButtonElement);
onsElements.Button = ButtonElement;
customElements.define('ons-button', ButtonElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$2 = 'card';
var scheme$4 = {
'': 'card--*',
'.card__title': 'card--*__title',
'.card__content': 'card--*__content'
};
/**
* @element ons-card
* @category visual
* @modifier material
* [en]A card with material design.[/en]
* [ja]リストの上下のボーダーが無いリストを表示します。[/ja]
* @description
* [en]
* Component to create a card that displays some information.
*
* The card may be composed by divs with specially prepared classes `title` and/or `content`. You can also add your own content as you please.[/en]
* [ja][/ja]
* @tutorial vanilla/Reference/card
* @example
*
*
Some content
*
*/
var CardElement = function (_BaseElement) {
inherits(CardElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the card.[/en]
* [ja]リストの表現を指定します。[/ja]
*/
function CardElement() {
classCallCheck(this, CardElement);
var _this = possibleConstructorReturn(this, (CardElement.__proto__ || Object.getPrototypeOf(CardElement)).call(this));
contentReady(_this, function () {
_this._compile();
});
return _this;
}
createClass(CardElement, [{
key: '_compile',
value: function _compile() {
for (var i = 0; i < this.children.length; i++) {
var el = this.children[i];
if (el.classList.contains('title')) {
el.classList.add('card__title');
} else if (el.classList.contains('content')) {
el.classList.add('card__content');
}
}
autoStyle.prepare(this);
this.classList.add(defaultClassName$2);
ModifierUtil.initModifier(this, scheme$4);
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$2, scheme$4);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$4);
break;
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class'];
}
}]);
return CardElement;
}(BaseElement);
onsElements.Card = CardElement;
customElements.define('ons-card', CardElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var scheme$5 = { '': 'carousel-item--*' };
/**
* @element ons-carousel-item
* @category carousel
* @description
* [en]
* Carousel item component. Used as a child of the `` element.
* [/en]
* [ja][/ja]
* @codepen xbbzOQ
* @tutorial vanilla/Reference/carousel
* @seealso ons-carousel
* [en]`` components[/en]
* [ja]コンポーネント[/ja]
* @example
*
*
* ...
*
*
* ...
*
*
*/
var CarouselItemElement = function (_BaseElement) {
inherits(CarouselItemElement, _BaseElement);
function CarouselItemElement() {
classCallCheck(this, CarouselItemElement);
var _this = possibleConstructorReturn(this, (CarouselItemElement.__proto__ || Object.getPrototypeOf(CarouselItemElement)).call(this));
_this.style.width = '100%';
ModifierUtil.initModifier(_this, scheme$5);
return _this;
}
createClass(CarouselItemElement, [{
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
if (name === 'modifier') {
return ModifierUtil.onModifierChanged(last, current, this, scheme$5);
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier'];
}
}]);
return CarouselItemElement;
}(BaseElement);
onsElements.CarouselItem = CarouselItemElement;
customElements.define('ons-carousel-item', CarouselItemElement);
var directionMap = {
vertical: {
axis: 'Y',
size: 'Height',
dir: ['up', 'down'],
t3d: ['0px, ', 'px, 0px']
},
horizontal: {
axis: 'X',
size: 'Width',
dir: ['left', 'right'],
t3d: ['', 'px, 0px, 0px']
}
};
var Swiper = function () {
function Swiper(params) {
var _this = this;
classCallCheck(this, Swiper);
// Parameters
var FALSE = function FALSE() {
return false;
};
'getInitialIndex getBubbleWidth isVertical isOverScrollable isCentered\n isAutoScrollable refreshHook preChangeHook postChangeHook overScrollHook'.split(/\s+/).forEach(function (key) {
return _this[key] = params[key] || FALSE;
});
this.getElement = params.getElement; // Required
this.scrollHook = params.scrollHook; // Optional
this.itemSize = params.itemSize || '100%';
this.getAutoScrollRatio = function () {
var ratio = params.getAutoScrollRatio && params.getAutoScrollRatio.apply(params, arguments);
ratio = typeof ratio === 'number' && ratio === ratio ? ratio : .5;
if (ratio < 0.0 || ratio > 1.0) {
util$1.throw('Invalid auto-scroll-ratio ' + ratio + '. Must be between 0 and 1');
}
return ratio;
};
// Prevent clicks only on desktop
this.shouldBlock = util$1.globals.actualMobileOS === 'other';
// Bind handlers
this.onDragStart = this.onDragStart.bind(this);
this.onDrag = this.onDrag.bind(this);
this.onDragEnd = this.onDragEnd.bind(this);
this.onResize = this.onResize.bind(this);
this._shouldFixScroll = util$1.globals.actualMobileOS === 'ios';
}
createClass(Swiper, [{
key: 'init',
value: function init() {
var _this2 = this;
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
swipeable = _ref.swipeable,
autoRefresh = _ref.autoRefresh;
this.initialized = true;
this.target = this.getElement().children[0];
this.blocker = this.getElement().children[1];
if (!this.target || !this.blocker) {
util$1.throw('Expected "target" and "blocker" elements to exist before initializing Swiper');
}
if (!this.shouldBlock) {
this.blocker.style.display = 'none';
}
// Add classes
this.getElement().classList.add('ons-swiper');
this.target.classList.add('ons-swiper-target');
this.blocker.classList.add('ons-swiper-blocker');
// Setup listeners
this._gestureDetector = new GestureDetector(this.getElement(), { dragMinDistance: 1, dragLockToAxis: true, passive: !this._shouldFixScroll });
this._mutationObserver = new MutationObserver(function () {
return _this2.refresh();
});
this.updateSwipeable(swipeable);
this.updateAutoRefresh(autoRefresh);
// Setup initial layout
this._scroll = this._offset = this._lastActiveIndex = 0;
this._updateLayout();
this._setupInitialIndex();
setImmediate(function () {
return _this2.initialized && _this2._setupInitialIndex();
});
// Fix rendering glitch on Android 4.1
// Fix for iframes where the width is inconsistent at the beginning
if (window !== window.parent || this.offsetHeight === 0) {
window.requestAnimationFrame(function () {
return _this2.initialized && _this2.onResize();
});
}
}
}, {
key: 'dispose',
value: function dispose() {
this.initialized = false;
this.updateSwipeable(false);
this.updateAutoRefresh(false);
this._gestureDetector && this._gestureDetector.dispose();
this.target = this.blocker = this._gestureDetector = this._mutationObserver = null;
this.setupResize(false);
}
}, {
key: 'onResize',
value: function onResize() {
var i = this._scroll / this.targetSize;
this._reset();
this.setActiveIndex(i);
this.refresh();
}
}, {
key: '_calculateItemSize',
value: function _calculateItemSize() {
var matches = this.itemSize.match(/^(\d+)(px|%)/);
if (!matches) {
util$1.throw('Invalid state: swiper\'s size unit must be \'%\' or \'px\'');
}
var value = parseInt(matches[1], 10);
return matches[2] === '%' ? Math.round(value / 100 * this.targetSize) : value;
}
}, {
key: '_setupInitialIndex',
value: function _setupInitialIndex() {
this._reset();
this._lastActiveIndex = Math.max(Math.min(Number(this.getInitialIndex()), this.itemCount), 0);
this._scroll = this._offset + this.itemNumSize * this._lastActiveIndex;
this._scrollTo(this._scroll);
}
}, {
key: '_setSwiping',
value: function _setSwiping(toggle) {
this.target.classList.toggle('swiping', toggle); // Hides everything except shown pages
}
}, {
key: 'setActiveIndex',
value: function setActiveIndex(index) {
var _this3 = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this._setSwiping(true);
index = Math.max(0, Math.min(index, this.itemCount - 1));
var scroll = Math.max(0, Math.min(this.maxScroll, this._offset + this.itemNumSize * index));
if (platform.isUIWebView()) {
/* Dirty fix for #2231(https://github.com/OnsenUI/OnsenUI/issues/2231). begin */
var concat = function concat(arrayOfArray) {
return Array.prototype.concat.apply([], arrayOfArray);
};
var contents = concat(util$1.arrayFrom(this.target.children).map(function (page) {
return util$1.arrayFrom(page.children).filter(function (child) {
return child.classList.contains('page__content');
});
}));
var map = new Map();
return new Promise(function (resolve) {
contents.forEach(function (content) {
map.set(content, content.getAttribute('class'));
content.classList.add('page__content--suppress-layer-creation');
});
requestAnimationFrame(resolve);
}).then(function () {
return _this3._changeTo(scroll, options);
}).then(function () {
return new Promise(function (resolve) {
contents.forEach(function (content) {
content.setAttribute('class', map.get(content));
});
requestAnimationFrame(resolve);
});
});
/* end */
} else {
return this._changeTo(scroll, options);
}
}
}, {
key: 'getActiveIndex',
value: function getActiveIndex() {
var scroll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._scroll;
scroll -= this._offset;
var count = this.itemCount,
size = this.itemNumSize;
if (this.itemNumSize === 0 || !util$1.isInteger(scroll)) {
return this._lastActiveIndex;
}
if (scroll <= 0) {
return 0;
}
for (var i = 0; i < count; i++) {
if (size * i <= scroll && size * (i + 1) > scroll) {
return i;
}
}
return count - 1;
}
}, {
key: 'setupResize',
value: function setupResize(add) {
window[(add ? 'add' : 'remove') + 'EventListener']('resize', this.onResize, true);
}
}, {
key: 'show',
value: function show() {
var _this4 = this;
this.setupResize(true);
this.onResize();
setTimeout(function () {
return _this4.target && _this4.target.classList.add('active');
}, 1000 / 60); // Hide elements after animations
}
}, {
key: 'hide',
value: function hide() {
this.setupResize(false);
this.target.classList.remove('active'); // Show elements before animations
}
}, {
key: 'updateSwipeable',
value: function updateSwipeable(shouldUpdate) {
if (this._gestureDetector) {
var action = shouldUpdate ? 'on' : 'off';
this._gestureDetector[action]('drag', this.onDrag);
this._gestureDetector[action]('dragstart', this.onDragStart);
this._gestureDetector[action]('dragend', this.onDragEnd);
}
}
}, {
key: 'updateAutoRefresh',
value: function updateAutoRefresh(shouldWatch) {
if (this._mutationObserver) {
shouldWatch ? this._mutationObserver.observe(this.target, { childList: true }) : this._mutationObserver.disconnect();
}
}
}, {
key: 'updateItemSize',
value: function updateItemSize(newSize) {
this.itemSize = newSize || '100%';
this.refresh();
}
}, {
key: 'toggleBlocker',
value: function toggleBlocker(block) {
this.blocker.style.pointerEvents = block ? 'auto' : 'none';
}
}, {
key: '_canConsumeGesture',
value: function _canConsumeGesture(gesture) {
var d = gesture.direction;
var isFirst = this._scroll === 0 && !this.isOverScrollable();
var isLast = this._scroll === this.maxScroll && !this.isOverScrollable();
return this.isVertical() ? d === 'down' && !isFirst || d === 'up' && !isLast : d === 'right' && !isFirst || d === 'left' && !isLast;
}
}, {
key: 'onDragStart',
value: function onDragStart(event) {
var _this5 = this;
this._ignoreDrag = event.consumed || !util$1.isValidGesture(event);
if (!this._ignoreDrag) {
var consume = event.consume;
event.consume = function () {
consume && consume();_this5._ignoreDrag = true;
};
if (this._canConsumeGesture(event.gesture)) {
var startX = event.gesture.center && event.gesture.center.clientX || 0,
distFromEdge = this.getBubbleWidth() || 0,
start = function start() {
consume && consume();
event.consumed = true;
_this5._started = true; // Avoid starting drag from outside
_this5.shouldBlock && _this5.toggleBlocker(true);
_this5._setSwiping(true);
util$1.iosPreventScroll(_this5._gestureDetector);
};
// Let parent elements consume the gesture or consume it right away
startX < distFromEdge || startX > this.targetSize - distFromEdge ? setImmediate(function () {
return !_this5._ignoreDrag && start();
}) : start();
}
}
}
}, {
key: 'onDrag',
value: function onDrag(event) {
if (!event.gesture || this._ignoreDrag || !this._started) {
return;
}
this._continued = true; // Fix for random 'dragend' without 'drag'
event.stopPropagation();
this._scrollTo(this._scroll - this._getDelta(event), { throttle: true });
}
}, {
key: 'onDragEnd',
value: function onDragEnd(event) {
this._started = false;
if (!event.gesture || this._ignoreDrag || !this._continued) {
this._ignoreDrag = true; // onDragEnd might fire before onDragStart's setImmediate
return;
}
this._continued = false;
event.stopPropagation();
var scroll = this._scroll - this._getDelta(event);
var normalizedScroll = this._normalizeScroll(scroll);
scroll === normalizedScroll ? this._startMomentumScroll(scroll, event) : this._killOverScroll(normalizedScroll);
this.shouldBlock && this.toggleBlocker(false);
}
}, {
key: '_startMomentumScroll',
value: function _startMomentumScroll(scroll, event) {
var velocity = this._getVelocity(event),
matchesDirection = event.gesture.interimDirection === this.dM.dir[this._getDelta(event) < 0 ? 0 : 1];
var nextScroll = this._getAutoScroll(scroll, velocity, matchesDirection);
var duration = Math.abs(nextScroll - scroll) / (velocity + 0.01) / 1000;
duration = Math.min(.25, Math.max(.1, duration));
this._changeTo(nextScroll, { swipe: true, animationOptions: { duration: duration, timing: 'cubic-bezier(.4, .7, .5, 1)' } });
}
}, {
key: '_killOverScroll',
value: function _killOverScroll(scroll) {
var _this6 = this;
this._scroll = scroll;
var direction = this.dM.dir[Number(scroll > 0)];
var killOverScroll = function killOverScroll() {
return _this6._changeTo(scroll, { animationOptions: { duration: .4, timing: 'cubic-bezier(.1, .4, .1, 1)' } });
};
this.overScrollHook({ direction: direction, killOverScroll: killOverScroll }) || killOverScroll();
}
}, {
key: '_changeTo',
value: function _changeTo(scroll) {
var _this7 = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var e = { activeIndex: this.getActiveIndex(scroll), lastActiveIndex: this._lastActiveIndex, swipe: options.swipe || false };
var change = e.activeIndex !== e.lastActiveIndex;
var canceled = change ? this.preChangeHook(e) : false;
this._scroll = canceled ? this._offset + e.lastActiveIndex * this.itemNumSize : scroll;
this._lastActiveIndex = canceled ? e.lastActiveIndex : e.activeIndex;
return this._scrollTo(this._scroll, options).then(function () {
if (scroll === _this7._scroll && !canceled) {
_this7._setSwiping(false);
change && _this7.postChangeHook(e);
} else if (options.reject) {
_this7._setSwiping(false);
return Promise.reject('Canceled');
}
});
}
}, {
key: '_scrollTo',
value: function _scrollTo(scroll) {
var _this8 = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (options.throttle) {
var ratio = 0.35;
if (scroll < 0) {
scroll = this.isOverScrollable() ? Math.round(scroll * ratio) : 0;
} else {
var maxScroll = this.maxScroll;
if (maxScroll < scroll) {
scroll = this.isOverScrollable() ? maxScroll + Math.round((scroll - maxScroll) * ratio) : maxScroll;
}
}
}
var opt = options.animation === 'none' ? {} : options.animationOptions;
this.scrollHook && this.itemNumSize > 0 && this.scrollHook((scroll / this.itemNumSize).toFixed(2), options.animationOptions || {});
return new Promise(function (resolve) {
return Animit(_this8.target).queue({ transform: _this8._getTransform(scroll) }, opt).play(resolve);
});
}
}, {
key: '_getAutoScroll',
value: function _getAutoScroll(scroll, velocity, matchesDirection) {
var max = this.maxScroll,
offset = this._offset,
size = this.itemNumSize;
if (!this.isAutoScrollable()) {
return Math.max(0, Math.min(max, scroll));
}
var arr = [];
for (var s = offset; s < max; s += size) {
arr.push(s);
}
arr.push(max);
arr = arr.sort(function (left, right) {
return Math.abs(left - scroll) - Math.abs(right - scroll);
}).filter(function (item, pos) {
return !pos || item !== arr[pos - 1];
});
var result = arr[0];
var lastScroll = this._lastActiveIndex * size + offset;
var scrollRatio = Math.abs(scroll - lastScroll) / size;
if (scrollRatio <= this.getAutoScrollRatio(matchesDirection, velocity, size)) {
result = lastScroll;
} else {
if (scrollRatio < 1.0 && arr[0] === lastScroll && arr.length > 1) {
result = arr[1];
}
}
return Math.max(0, Math.min(max, result));
}
}, {
key: '_reset',
value: function _reset() {
this._targetSize = this._itemNumSize = undefined;
}
}, {
key: '_normalizeScroll',
value: function _normalizeScroll(scroll) {
return Math.max(Math.min(scroll, this.maxScroll), 0);
}
}, {
key: 'refresh',
value: function refresh() {
this._reset();
this._updateLayout();
if (util$1.isInteger(this._scroll)) {
var scroll = this._normalizeScroll(this._scroll);
scroll !== this._scroll ? this._killOverScroll(scroll) : this._changeTo(scroll);
} else {
this._setupInitialIndex();
}
this.refreshHook();
}
}, {
key: '_getDelta',
value: function _getDelta(event) {
return event.gesture['delta' + this.dM.axis];
}
}, {
key: '_getVelocity',
value: function _getVelocity(event) {
return event.gesture['velocity' + this.dM.axis];
}
}, {
key: '_getTransform',
value: function _getTransform(scroll) {
return 'translate3d(' + this.dM.t3d[0] + -scroll + this.dM.t3d[1] + ')';
}
}, {
key: '_updateLayout',
value: function _updateLayout() {
this.dM = directionMap[this.isVertical() ? 'vertical' : 'horizontal'];
this.target.classList.toggle('ons-swiper-target--vertical', this.isVertical());
for (var c = this.target.children[0]; c; c = c.nextElementSibling) {
c.style[this.dM.size.toLowerCase()] = this.itemSize;
}
if (this.isCentered()) {
this._offset = (this.targetSize - this.itemNumSize) / -2 || 0;
}
}
}, {
key: 'itemCount',
get: function get$$1() {
return this.target.children.length;
}
}, {
key: 'itemNumSize',
get: function get$$1() {
if (typeof this._itemNumSize !== 'number' || this._itemNumSize !== this._itemNumSize) {
this._itemNumSize = this._calculateItemSize();
}
return this._itemNumSize;
}
}, {
key: 'maxScroll',
get: function get$$1() {
var max = this.itemCount * this.itemNumSize - this.targetSize;
return Math.ceil(max < 0 ? 0 : max); // Need to return an integer value.
}
}, {
key: 'targetSize',
get: function get$$1() {
if (!this._targetSize) {
this._targetSize = this.target['offset' + this.dM.size];
}
return this._targetSize;
}
}]);
return Swiper;
}();
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-carousel
* @category carousel
* @description
* [en]
* Carousel component. A carousel can be used to display several items in the same space.
*
* The component supports displaying content both horizontally and vertically. The user can scroll through the items by dragging and it can also be controller programmatically.
* [/en]
* [ja][/ja]
* @codepen xbbzOQ
* @tutorial vanilla/Reference/carousel
* @seealso ons-carousel-item
* [en]`` component[/en]
* [ja]ons-carousel-itemコンポーネント[/ja]
* @example
*
*
* ...
*
*
* ...
*
*
*/
var CarouselElement = function (_BaseElement) {
inherits(CarouselElement, _BaseElement);
/**
* @event postchange
* @description
* [en]Fired just after the current carousel item has changed.[/en]
* [ja]現在表示しているカルーセルの要素が変わった時に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.carousel
* [en]Carousel object.[/en]
* [ja]イベントが発火したCarouselオブジェクトです。[/ja]
* @param {Number} event.activeIndex
* [en]Current active index.[/en]
* [ja]現在アクティブになっている要素のインデックス。[/ja]
* @param {Number} event.lastActiveIndex
* [en]Previous active index.[/en]
* [ja]以前アクティブだった要素のインデックス。[/ja]
*/
/**
* @event refresh
* @description
* [en]Fired when the carousel has been refreshed.[/en]
* [ja]カルーセルが更新された時に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.carousel
* [en]Carousel object.[/en]
* [ja]イベントが発火したCarouselオブジェクトです。[/ja]
*/
/**
* @event overscroll
* @description
* [en]Fired when the carousel has been overscrolled.[/en]
* [ja]カルーセルがオーバースクロールした時に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.carousel
* [en]Fired when the carousel has been refreshed.[/en]
* [ja]カルーセルが更新された時に発火します。[/ja]
* @param {Number} event.activeIndex
* [en]Current active index.[/en]
* [ja]現在アクティブになっている要素のインデックス。[/ja]
* @param {String} event.direction
* [en]Can be one of either "up", "down", "left" or "right".[/en]
* [ja]オーバースクロールされた方向が得られます。"up", "down", "left", "right"のいずれかの方向が渡されます。[/ja]
* @param {Function} event.waitToReturn
* [en]Takes a Promise object as an argument. The carousel will not scroll back until the promise has been resolved or rejected.[/en]
* [ja]この関数はPromiseオブジェクトを引数として受け取ります。渡したPromiseオブジェクトがresolveされるかrejectされるまで、カルーセルはスクロールバックしません。[/ja]
*/
/**
* @attribute direction
* @type {String}
* @description
* [en]The direction of the carousel. Can be either "horizontal" or "vertical". Default is "horizontal".[/en]
* [ja]カルーセルの方向を指定します。"horizontal"か"vertical"を指定できます。"horizontal"がデフォルト値です。[/ja]
*/
/**
* @attribute fullscreen
* @description
* [en]If this attribute is set the carousel will cover the whole screen.[/en]
* [ja]この属性があると、absoluteポジションを使ってカルーセルが自動的に画面いっぱいに広がります。[/ja]
*/
/**
* @attribute overscrollable
* @description
* [en]If this attribute is set the carousel will be scrollable over the edge. It will bounce back when released.[/en]
* [ja]この属性がある時、タッチやドラッグで端までスクロールした時に、バウンドするような効果が当たります。[/ja]
*/
/**
* @attribute centered
* @description
* [en]If this attribute is set the carousel then the selected item will be in the center of the carousel instead of the beginning. Useful only when the items are smaller than the carousel. [/en]
* [ja]この属性がある時、選んでいるons-carousel-itemはカルーセルの真ん中へ行きます。項目がカルーセルよりも小さい場合にのみ、これは便利です。[/ja]
*/
/**
* @attribute item-width
* @type {String}
* @description
* [en]ons-carousel-item's width. Only works when the direction is set to "horizontal".[/en]
* [ja]ons-carousel-itemの幅を指定します。この属性は、direction属性に"horizontal"を指定した時のみ有効になります。[/ja]
*/
/**
* @attribute item-height
* @type {String}
* @description
* [en]ons-carousel-item's height. Only works when the direction is set to "vertical".[/en]
* [ja]ons-carousel-itemの高さを指定します。この属性は、direction属性に"vertical"を指定した時のみ有効になります。[/ja]
*/
/**
* @attribute auto-scroll
* @description
* [en]If this attribute is set the carousel will be automatically scrolled to the closest item border when released.[/en]
* [ja]この属性がある時、一番近いcarousel-itemの境界まで自動的にスクロールするようになります。[/ja]
*/
/**
* @attribute auto-scroll-ratio
* @type {Number}
* @description
* [en]A number between 0.0 and 1.0 that specifies how much the user must drag the carousel in order for it to auto scroll to the next item.[/en]
* [ja]0.0から1.0までの値を指定します。カルーセルの要素をどれぐらいの割合までドラッグすると次の要素に自動的にスクロールするかを指定します。[/ja]
*/
/**
* @attribute swipeable
* @description
* [en]If this attribute is set the carousel can be scrolled by drag or swipe.[/en]
* [ja]この属性がある時、カルーセルをスワイプやドラッグで移動できるようになります。[/ja]
*/
/**
* @attribute disabled
* @description
* [en]If this attribute is set the carousel is disabled.[/en]
* [ja]この属性がある時、dragやtouchやswipeを受け付けなくなります。[/ja]
*/
/**
* @attribute initial-index
* @initonly
* @default 0
* @type {Number}
* @description
* [en]Specify the index of the ons-carousel-item to show initially. Default is 0.[/en]
* [ja]最初に表示するons-carousel-itemを0始まりのインデックスで指定します。デフォルト値は 0 です。[/ja]
*/
/**
* @attribute auto-refresh
* @description
* [en]When this attribute is set the carousel will automatically refresh when the number of child nodes change.[/en]
* [ja]この属性がある時、子要素の数が変わるとカルーセルは自動的に更新されるようになります。[/ja]
*/
/**
* @attribute animation
* @type {String}
* @description
* [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
* [ja][/ja]
*/
/**
* @attribute animation-options
* @type {Expression}
* @description
* [en]Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。例:{duration: 0.2, delay: 1, timing: 'ease-in'}[/ja]
*/
function CarouselElement() {
classCallCheck(this, CarouselElement);
var _this = possibleConstructorReturn(this, (CarouselElement.__proto__ || Object.getPrototypeOf(CarouselElement)).call(this));
contentReady(_this, function () {
return _this._compile();
});
return _this;
}
createClass(CarouselElement, [{
key: '_compile',
value: function _compile() {
var target = this.children[0] && this.children[0].tagName !== 'ONS-CAROUSEL-ITEM' && this.children[0] || document.createElement('div');
if (!target.parentNode) {
while (this.firstChild) {
target.appendChild(this.firstChild);
}
this.appendChild(target);
}
!this.children[1] && this.appendChild(document.createElement('div'));
this.appendChild = this.appendChild.bind(target);
this.insertBefore = this.insertBefore.bind(target);
}
}, {
key: 'connectedCallback',
value: function connectedCallback() {
var _this2 = this;
if (!this._swiper) {
this._swiper = new Swiper({
getElement: function getElement() {
return _this2;
},
getInitialIndex: function getInitialIndex() {
return _this2.getAttribute('initial-index');
},
getAutoScrollRatio: function getAutoScrollRatio() {
return _this2.autoScrollRatio;
},
isVertical: function isVertical() {
return _this2.vertical;
},
isOverScrollable: function isOverScrollable() {
return _this2.overscrollable;
},
isCentered: function isCentered() {
return _this2.centered;
},
isAutoScrollable: function isAutoScrollable() {
return _this2.autoScroll;
},
itemSize: this.itemSize,
overScrollHook: this._onOverScroll.bind(this),
preChangeHook: this._onChange.bind(this, 'prechange'),
postChangeHook: this._onChange.bind(this, 'postchange'),
refreshHook: this._onRefresh.bind(this),
scrollHook: function scrollHook() {
return _this2._onSwipe && _this2._onSwipe.apply(_this2, arguments);
}
});
contentReady(this, function () {
return _this2._swiper.init({
swipeable: _this2.hasAttribute('swipeable'),
autoRefresh: _this2.hasAttribute('auto-refresh')
});
});
}
}
}, {
key: 'disconnectedCallback',
value: function disconnectedCallback() {
if (this._swiper && this._swiper.initialized) {
this._swiper.dispose();
this._swiper = null;
}
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
if (!this._swiper) {
return;
}
switch (name) {
case 'swipeable':
this._swiper.updateSwipeable(this.hasAttribute('swipeable'));
break;
case 'auto-refresh':
this._swiper.updateAutoRefresh(this.hasAttribute('auto-refresh'));
break;
case 'item-height':
this.vertical && this._swiper.updateItemSize(this.itemSize);
break;
case 'item-width':
this.vertical || this._swiper.updateItemSize(this.itemSize);
break;
case 'direction':
this._swiper.refresh();
}
}
}, {
key: '_show',
value: function _show() {
this._swiper.show();
}
}, {
key: '_hide',
value: function _hide() {
this._swiper.hide();
}
}, {
key: '_onOverScroll',
value: function _onOverScroll(_ref) {
var direction = _ref.direction,
killOverScroll = _ref.killOverScroll;
var waitForAction = false;
util$1.triggerElementEvent(this, 'overscroll', {
carousel: this,
activeIndex: this.getActiveIndex(),
direction: direction,
waitToReturn: function waitToReturn(promise) {
waitForAction = true;
promise.then(killOverScroll);
}
});
return waitForAction;
}
}, {
key: '_onChange',
value: function _onChange(eventName, _ref2) {
var activeIndex = _ref2.activeIndex,
lastActiveIndex = _ref2.lastActiveIndex;
util$1.triggerElementEvent(this, eventName, { carousel: this, activeIndex: activeIndex, lastActiveIndex: lastActiveIndex });
}
}, {
key: '_onRefresh',
value: function _onRefresh() {
util$1.triggerElementEvent(this, 'refresh', { carousel: this });
}
/**
* @method setActiveIndex
* @signature setActiveIndex(index, [options])
* @param {Number} index
* [en]The index that the carousel should be set to.[/en]
* [ja]carousel要素のインデックスを指定します。[/ja]
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja][/ja]
* @param {Function} [options.callback]
* [en]A function that will be called after the animation is finished.[/en]
* [ja][/ja]
* @param {String} [options.animation]
* [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
* [ja][/ja]
* @param {Object} [options.animationOptions]
* [en]An object that can be used to specify duration, delay and timing function of the animation.[/en]
* [ja][/ja]
* @description
* [en]Specify the index of the `` to show.[/en]
* [ja]表示するons-carousel-itemをindexで指定します。[/ja]
* @return {Promise}
* [en]Resolves to the carousel element.[/en]
* [ja][/ja]
*/
}, {
key: 'setActiveIndex',
value: function setActiveIndex(index) {
var _this3 = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options = _extends({
animation: this.getAttribute('animation'),
animationOptions: this.hasAttribute('animation-options') ? util$1.animationOptionsParse(this.getAttribute('animation-options')) : { duration: .3, timing: 'cubic-bezier(.4, .7, .5, 1)' }
}, options);
return this._swiper.setActiveIndex(index, options).then(function () {
options.callback instanceof Function && options.callback(_this3);
return Promise.resolve(_this3);
});
}
/**
* @method getActiveIndex
* @signature getActiveIndex()
* @return {Number}
* [en]The current carousel item index.[/en]
* [ja]現在表示しているカルーセル要素のインデックスが返されます。[/ja]
* @description
* [en]Returns the index of the currently visible ``.[/en]
* [ja]現在表示されているons-carousel-item要素のインデックスを返します。[/ja]
*/
}, {
key: 'getActiveIndex',
value: function getActiveIndex() {
return this._swiper.getActiveIndex();
}
/**
* @method next
* @signature next([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja][/ja]
* @param {Function} [options.callback]
* [en]A function that will be executed after the animation has finished.[/en]
* [ja][/ja]
* @param {String} [options.animation]
* [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
* [ja][/ja]
* @param {Object} [options.animationOptions]
* [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Resolves to the carousel element[/en]
* [ja][/ja]
* @description
* [en]Show next ``.[/en]
* [ja]次のons-carousel-itemを表示します。[/ja]
*/
}, {
key: 'next',
value: function next(options) {
return this.setActiveIndex(this.getActiveIndex() + 1, options);
}
/**
* @method prev
* @signature prev([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja][/ja]
* @param {Function} [options.callback]
* [en]A function that will be executed after the animation has finished.[/en]
* [ja][/ja]
* @param {String} [options.animation]
* [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
* [ja][/ja]
* @param {Object} [options.animationOptions]
* [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Resolves to the carousel element[/en]
* [ja][/ja]
* @description
* [en]Show previous ``.[/en]
* [ja]前のons-carousel-itemを表示します。[/ja]
*/
}, {
key: 'prev',
value: function prev(options) {
return this.setActiveIndex(this.getActiveIndex() - 1, options);
}
/**
* @method first
* @signature first()
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja][/ja]
* @param {Function} [options.callback]
* [en]A function that will be executed after the animation has finished.[/en]
* [ja][/ja]
* @param {String} [options.animation]
* [en]If this is set to `"none"`, the transitions will not be animated.[/en]
* [ja][/ja]
* @param {Object} [options.animationOptions]
* [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Resolves to the carousel element[/en]
* [ja][/ja]
* @description
* [en]Show first ``.[/en]
* [ja]最初のons-carousel-itemを表示します。[/ja]
*/
}, {
key: 'first',
value: function first(options) {
return this.setActiveIndex(0, options);
}
/**
* @method last
* @signature last()
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja][/ja]
* @param {Function} [options.callback]
* [en]A function that will be executed after the animation has finished.[/en]
* [ja][/ja]
* @param {String} [options.animation]
* [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
* [ja][/ja]
* @param {Object} [options.animationOptions]
* [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
* [ja][/ja]
* @return {Promise}
* [en]Resolves to the carousel element[/en]
* [ja]Resolves to the carousel element[/ja]
* @description
* [en]Show last ons-carousel item.[/en]
* [ja]最後のons-carousel-itemを表示します。[/ja]
*/
}, {
key: 'last',
value: function last(options) {
this.setActiveIndex(Math.max(this.itemCount - 1, 0), options);
}
/**
* @method refresh
* @signature refresh()
* @description
* [en]Update the layout of the carousel. Used when adding `` dynamically or to automatically adjust the size.[/en]
* [ja]レイアウトや内部の状態を最新のものに更新します。ons-carousel-itemを動的に増やしたり、ons-carouselの大きさを動的に変える際に利用します。[/ja]
*/
}, {
key: 'refresh',
value: function refresh() {
this._swiper.refresh();
}
/**
* @property itemCount
* @readonly
* @type {Number}
* @description
* [en]The number of carousel items.[/en]
* [ja]カルーセル要素の数です。[/ja]
*/
}, {
key: 'itemCount',
get: function get$$1() {
return this._swiper.itemCount;
}
/**
* @property swipeable
* @type {Boolean}
* @description
* [en]true if the carousel is swipeable.[/en]
* [ja]swipeableであればtrueを返します。[/ja]
*/
}, {
key: 'swipeable',
get: function get$$1() {
return this.hasAttribute('swipeable');
},
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'swipeable', value);
}
/**
* @property onSwipe
* @type {Function}
* @description
* [en]Hook called whenever the user slides the carousel. It gets a decimal index and an animationOptions object as arguments.[/en]
* [ja][/ja]
*/
}, {
key: 'onSwipe',
get: function get$$1() {
return this._onSwipe;
},
set: function set$$1(value) {
if (value && !(value instanceof Function)) {
util$1.throw('"onSwipe" must be a function');
}
this._onSwipe = value;
}
/**
* @property autoScroll
* @type {Boolean}
* @description
* [en]true if auto scroll is enabled.[/en]
* [ja]オートスクロールが有効であればtrueを返します。[/ja]
*/
}, {
key: 'autoScroll',
get: function get$$1() {
return this.hasAttribute('auto-scroll');
},
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'auto-scroll', value);
}
}, {
key: 'vertical',
get: function get$$1() {
return this.getAttribute('direction') === 'vertical';
}
}, {
key: 'itemSize',
get: function get$$1() {
var itemSizeAttr = (this.getAttribute('item-' + (this.vertical ? 'height' : 'width')) || '').trim();
return itemSizeAttr.match(/^\d+(px|%)$/) ? itemSizeAttr : '100%';
}
/**
* @property autoScrollRatio
* @type {Number}
* @description
* [en]The current auto scroll ratio. [/en]
* [ja]現在のオートスクロールのratio値。[/ja]
*/
}, {
key: 'autoScrollRatio',
get: function get$$1() {
return parseFloat(this.getAttribute('auto-scroll-ratio'));
},
set: function set$$1(ratio) {
this.setAttribute('auto-scroll-ratio', ratio);
}
/**
* @property disabled
* @type {Boolean}
* @description
* [en]Whether the carousel is disabled or not.[/en]
* [ja]無効化されている場合に`true`。[/ja]
*/
}, {
key: 'disabled',
get: function get$$1() {
return this.hasAttribute('disabled');
},
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'disabled', value);
}
/**
* @property overscrollable
* @type {Boolean}
* @description
* [en]Whether the carousel is overscrollable or not.[/en]
* [ja]overscrollできればtrueを返します。[/ja]
*/
}, {
key: 'overscrollable',
get: function get$$1() {
return this.hasAttribute('overscrollable');
},
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'overscrollable', value);
}
/**
* @property centered
* @type {Boolean}
* @description
* [en]Whether the carousel is centered or not.[/en]
* [ja]centered状態になっていればtrueを返します。[/ja]
*/
}, {
key: 'centered',
get: function get$$1() {
return this.hasAttribute('centered');
},
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'centered', value);
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['swipeable', 'auto-refresh', 'direction', 'item-height', 'item-width'];
}
}, {
key: 'events',
get: function get$$1() {
return ['postchange', 'refresh', 'overscroll'];
}
}]);
return CarouselElement;
}(BaseElement);
onsElements.Carousel = CarouselElement;
customElements.define('ons-carousel', CarouselElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-col
* @category grid
* @description
* [en]Represents a column in the grid system. Use with `` to layout components.[/en]
* [ja]グリッドシステムにて列を定義します。ons-rowとともに使用し、コンポーネントのレイアウトに利用します。[/ja]
* @note
* [en]For Android 4.3 and earlier, and iOS6 and earlier, when using mixed alignment with ons-row and ons-column, they may not be displayed correctly. You can use only one alignment.[/en]
* [ja]Android 4.3以前、もしくはiOS 6以前のOSの場合、ons-rowとons-columnを組み合わせた場合に描画が崩れる場合があります。[/ja]
* @codepen GgujC {wide}
* @guide theming.html [en]Layouting guide[/en][ja]レイアウト機能[/ja]
* @seealso ons-row
* [en]The `` component is the parent of ``.[/en]
* [ja]ons-rowコンポーネント[/ja]
* @example
*
*
* Text
*
*/
/**
* @attribute vertical-align
* @type {String}
* @description
* [en]Vertical alignment of the column. Valid values are "top", "center", and "bottom".[/en]
* [ja]縦の配置を指定する。"top", "center", "bottom"のいずれかを指定します。[/ja]
*/
/**
* @attribute width
* @type {String}
* @description
* [en]The width of the column. Valid values are css width values ("10%", "50px").[/en]
* [ja]カラムの横幅を指定する。パーセントもしくはピクセルで指定します(10%や50px)。[/ja]
*/
var ColElement = function (_BaseElement) {
inherits(ColElement, _BaseElement);
function ColElement() {
classCallCheck(this, ColElement);
var _this = possibleConstructorReturn(this, (ColElement.__proto__ || Object.getPrototypeOf(ColElement)).call(this));
if (_this.getAttribute('width')) {
_this._updateWidth();
}
return _this;
}
createClass(ColElement, [{
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
if (name === 'width') {
this._updateWidth();
}
}
}, {
key: '_updateWidth',
value: function _updateWidth() {
var width = this.getAttribute('width');
if (!width) {
styler.clear(this, 'flex maxWidth');
} else {
width = width.trim().match(/^\d+$/) ? width + '%' : width;
styler(this, {
flex: '0 0 ' + width,
maxWidth: width
});
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['width'];
}
}]);
return ColElement;
}(BaseElement);
onsElements.Col = ColElement;
customElements.define('ons-col', ColElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var DialogAnimator = function (_BaseAnimator) {
inherits(DialogAnimator, _BaseAnimator);
function DialogAnimator() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$timing = _ref.timing,
timing = _ref$timing === undefined ? 'linear' : _ref$timing,
_ref$delay = _ref.delay,
delay = _ref$delay === undefined ? 0 : _ref$delay,
_ref$duration = _ref.duration,
duration = _ref$duration === undefined ? 0.2 : _ref$duration;
classCallCheck(this, DialogAnimator);
return possibleConstructorReturn(this, (DialogAnimator.__proto__ || Object.getPrototypeOf(DialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
}
/**
* @param {HTMLElement} dialog
* @param {Function} done
*/
createClass(DialogAnimator, [{
key: 'show',
value: function show(dialog, done) {
done();
}
/**
* @param {HTMLElement} dialog
* @param {Function} done
*/
}, {
key: 'hide',
value: function hide(dialog, done) {
done();
}
}]);
return DialogAnimator;
}(BaseAnimator);
/**
* Android style animator for dialog.
*/
var AndroidDialogAnimator = function (_DialogAnimator) {
inherits(AndroidDialogAnimator, _DialogAnimator);
function AndroidDialogAnimator() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref2$timing = _ref2.timing,
timing = _ref2$timing === undefined ? 'ease-in-out' : _ref2$timing,
_ref2$delay = _ref2.delay,
delay = _ref2$delay === undefined ? 0 : _ref2$delay,
_ref2$duration = _ref2.duration,
duration = _ref2$duration === undefined ? 0.3 : _ref2$duration;
classCallCheck(this, AndroidDialogAnimator);
return possibleConstructorReturn(this, (AndroidDialogAnimator.__proto__ || Object.getPrototypeOf(AndroidDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
createClass(AndroidDialogAnimator, [{
key: 'show',
value: function show(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -60%, 0)', opacity: 0 }, { transform: 'translate3d(-50%, -50%, 0)', opacity: 1 }).queue(function (done) {
callback();
done();
}));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
}, {
key: 'hide',
value: function hide(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0)', opacity: 1 }, { transform: 'translate3d(-50%, -60%, 0)', opacity: 0 }).queue(function (done) {
callback();
done();
}));
}
}]);
return AndroidDialogAnimator;
}(DialogAnimator);
/**
* iOS style animator for dialog.
*/
var IOSDialogAnimator = function (_DialogAnimator2) {
inherits(IOSDialogAnimator, _DialogAnimator2);
function IOSDialogAnimator() {
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref3$timing = _ref3.timing,
timing = _ref3$timing === undefined ? 'ease-in-out' : _ref3$timing,
_ref3$delay = _ref3.delay,
delay = _ref3$delay === undefined ? 0 : _ref3$delay,
_ref3$duration = _ref3.duration,
duration = _ref3$duration === undefined ? 0.2 : _ref3$duration;
classCallCheck(this, IOSDialogAnimator);
var _this3 = possibleConstructorReturn(this, (IOSDialogAnimator.__proto__ || Object.getPrototypeOf(IOSDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
_this3.bodyHeight = document.body.clientHeight; // avoid Forced Synchronous Layout
return _this3;
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
createClass(IOSDialogAnimator, [{
key: 'show',
value: function show(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, ' + (this.bodyHeight / 2.0 - 1) + 'px, 0)' }, { transform: 'translate3d(-50%, -50%, 0)' }).queue(function (done) {
callback();
done();
}));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
}, {
key: 'hide',
value: function hide(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0)' }, { transform: 'translate3d(-50%, ' + (this.bodyHeight / 2.0 - 1) + 'px, 0)' }).queue(function (done) {
callback();
done();
}));
}
}]);
return IOSDialogAnimator;
}(DialogAnimator);
/**
* Slide animator for dialog.
*/
var SlideDialogAnimator = function (_DialogAnimator3) {
inherits(SlideDialogAnimator, _DialogAnimator3);
function SlideDialogAnimator() {
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref4$timing = _ref4.timing,
timing = _ref4$timing === undefined ? 'cubic-bezier(.1, .7, .4, 1)' : _ref4$timing,
_ref4$delay = _ref4.delay,
delay = _ref4$delay === undefined ? 0 : _ref4$delay,
_ref4$duration = _ref4.duration,
duration = _ref4$duration === undefined ? 0.2 : _ref4$duration;
classCallCheck(this, SlideDialogAnimator);
var _this4 = possibleConstructorReturn(this, (SlideDialogAnimator.__proto__ || Object.getPrototypeOf(SlideDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
_this4.bodyHeight = document.body.clientHeight; // avoid Forced Synchronous Layout
return _this4;
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
createClass(SlideDialogAnimator, [{
key: 'show',
value: function show(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), Animit(dialog._dialog, this.def).default(
// FIXME: This should avoid Forced Synchronous Layout. Otherwise, fade animation of mask will be broken.
{ transform: 'translate3d(-50%, ' + (-(this.bodyHeight / 2.0) + 1 - dialog._dialog.clientHeight) + 'px, 0)' }, { transform: 'translate3d(-50%, -50%, 0)' }).queue(function (done) {
callback();
done();
}));
}
/**
* @param {Object} dialog
* @param {Function} callback
*/
}, {
key: 'hide',
value: function hide(dialog, callback) {
callback = callback ? callback : function () {};
Animit.runAll(Animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), Animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0)' },
// FIXME: This should avoid Forced Synchronous Layout. Otherwise, fade animation of mask will be broken.
{ transform: 'translate3d(-50%, ' + (-(this.bodyHeight / 2.0) + 1 - dialog._dialog.clientHeight) + 'px, 0)' }).queue(function (done) {
callback();
done();
}));
}
}]);
return SlideDialogAnimator;
}(DialogAnimator);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var scheme$6 = {
'.dialog': 'dialog--*',
'.dialog-container': 'dialog-container--*',
'.dialog-mask': 'dialog-mask--*'
};
var _animatorDict$2 = {
'default': function _default() {
return platform.isAndroid() ? AndroidDialogAnimator : IOSDialogAnimator;
},
'slide': SlideDialogAnimator,
'none': DialogAnimator
};
/**
* @element ons-dialog
* @category dialog
* @description
* [en]
* Dialog that is displayed on top of current screen. As opposed to the `` element, this component can contain any kind of content.
*
* To use the element it can either be attached directly to the `` element or dynamically created from a template using the `ons.createDialog(template)` utility function and the `` tag.
*
* The dialog is useful for displaying menus, additional information or to ask the user to make a decision.
*
* It will automatically be displayed as Material Design when running on an Android device.
* [/en]
* [ja][/ja]
* @modifier material
* [en]Display a Material Design dialog.[/en]
* [ja]マテリアルデザインのダイアログを表示します。[/ja]
* @codepen zxxaGa
* @tutorial vanilla/Reference/dialog
* @guide theming.html#modifiers [en]More details about the `modifier` attribute[/en][ja]modifier属性の使い方[/ja]
* @seealso ons-alert-dialog
* [en]`` component[/en]
* [ja]ons-alert-dialogコンポーネント[/ja]
* @seealso ons-popover
* [en]`` component[/en]
* [ja]ons-popoverコンポーネント[/ja]
* @seealso ons-modal
* [en]`` component[/en]
* [ja]ons-modalコンポーネント[/ja]
* @example
*
*
This is a dialog!
*
*
*
*/
var DialogElement = function (_BaseDialogElement) {
inherits(DialogElement, _BaseDialogElement);
/**
* @event preshow
* @description
* [en]Fired just before the dialog is displayed.[/en]
* [ja]ダイアログが表示される直前に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.dialog
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Execute this function to stop the dialog from being shown.[/en]
* [ja]この関数を実行すると、ダイアログの表示がキャンセルされます。[/ja]
*/
/**
* @event postshow
* @description
* [en]Fired just after the dialog is displayed.[/en]
* [ja]ダイアログが表示された直後に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.dialog
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @event prehide
* @description
* [en]Fired just before the dialog is hidden.[/en]
* [ja]ダイアログが隠れる直前に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.dialog
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Execute this function to stop the dialog from being hidden.[/en]
* [ja]この関数を実行すると、ダイアログの非表示がキャンセルされます。[/ja]
*/
/**
* @event posthide
* @description
* [en]Fired just after the dialog is hidden.[/en]
* [ja]ダイアログが隠れた後に発火します。[/ja]
* @param {Object} event [en]Event object.[/en]
* @param {Object} event.dialog
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the dialog.[/en]
* [ja]ダイアログの表現を指定します。[/ja]
*/
/**
* @attribute cancelable
* @description
* [en]If this attribute is set the dialog can be closed by tapping the background or by pressing the back button on Android devices.[/en]
* [ja][/ja]
*/
/**
* @attribute disabled
* @description
* [en]If this attribute is set the dialog is disabled.[/en]
* [ja]この属性がある時、ダイアログはdisabled状態になります。[/ja]
*/
/**
* @attribute animation
* @type {String}
* @default default
* @description
* [en]The animation used when showing and hiding the dialog. Can be either `"none"` or `"default"`.[/en]
* [ja]ダイアログを表示する際のアニメーション名を指定します。"none"もしくは"default"を指定できます。[/ja]
*/
/**
* @attribute animation-options
* @type {Expression}
* @description
* [en]Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。e.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`[/ja]
*/
/**
* @attribute mask-color
* @type {String}
* @default rgba(0, 0, 0, 0.2)
* @description
* [en]Color of the background mask. Default is `"rgba(0, 0, 0, 0.2)"`.[/en]
* [ja]背景のマスクの色を指定します。"rgba(0, 0, 0, 0.2)"がデフォルト値です。[/ja]
*/
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$2,
baseClass: DialogAnimator,
baseClassName: 'DialogAnimator',
defaultAnimation: this.getAttribute('animation')
});
}
}, {
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.style.display = 'none';
this.style.zIndex = 10001;
/* Expected result:
*
*
*
*
...
*
*
*/
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);
}
/**
* @property onDeviceBackButton
* @type {Object}
* @description
* [en]Back-button handler.[/en]
* [ja]バックボタンハンドラ。[/ja]
*/
/**
* @method show
* @signature show([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {String} [options.animation]
* [en]Animation name. Available animations are `"none"` and `"slide"`.[/en]
* [ja]アニメーション名を指定します。"none", "slide"のいずれかを指定します。[/ja]
* @param {String} [options.animationOptions]
* [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, delay, timingを指定します。e.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}` [/ja]
* @param {Function} [options.callback]
* [en]This function is called after the dialog has been revealed.[/en]
* [ja]ダイアログが表示され終わった後に呼び出される関数オブジェクトを指定します。[/ja]
* @description
* [en]Show the dialog.[/en]
* [ja]ダイアログを開きます。[/ja]
* @return {Promise} Resolves to the displayed element.
*/
/**
* @method hide
* @signature hide([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {String} [options.animation]
* [en]Animation name. Available animations are `"none"` and `"slide"`.[/en]
* [ja]アニメーション名を指定します。"none", "slide"のいずれかを指定できます。[/ja]
* @param {String} [options.animationOptions]
* [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]
* [ja]アニメーション時のduration, delay, timingを指定します。e.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`[/ja]
* @param {Function} [options.callback]
* [en]This functions is called after the dialog has been hidden.[/en]
* [ja]ダイアログが隠れた後に呼び出される関数オブジェクトを指定します。[/ja]
* @description
* [en]Hide the dialog.[/en]
* [ja]ダイアログを閉じます。[/ja]
* @return {Promise}
* [en]Resolves to the hidden element[/en]
* [ja][/ja]
*/
/**
* @property visible
* @readonly
* @type {Boolean}
* @description
* [en]Whether the dialog is visible or not.[/en]
* [ja]要素が見える場合に`true`。[/ja]
*/
/**
* @property disabled
* @type {Boolean}
* @description
* [en]Whether the dialog is disabled or not.[/en]
* [ja]無効化されている場合に`true`。[/ja]
*/
/**
* @property cancelable
* @type {Boolean}
* @description
* [en]Whether the dialog is cancelable or not. A cancelable dialog can be closed by tapping the background or by pressing the back button on Android devices.[/en]
* [ja][/ja]
*/
/**
* @param {String} name
* @param {DialogAnimator} Animator
*/
}, {
key: '_scheme',
get: function get$$1() {
return scheme$6;
}
}, {
key: '_mask',
get: function get$$1() {
return util$1.findChild(this, '.dialog-mask');
}
}, {
key: '_dialog',
get: function get$$1() {
return util$1.findChild(this, '.dialog');
}
}], [{
key: 'registerAnimator',
value: function registerAnimator(name, Animator) {
if (!(Animator.prototype instanceof DialogAnimator)) {
util$1.throwAnimator('Dialog');
}
_animatorDict$2[name] = Animator;
}
}, {
key: 'animators',
get: function get$$1() {
return _animatorDict$2;
}
}, {
key: 'DialogAnimator',
get: function get$$1() {
return DialogAnimator;
}
}]);
return DialogElement;
}(BaseDialogElement);
onsElements.Dialog = DialogElement;
customElements.define('ons-dialog', DialogElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$3 = 'fab';
var scheme$7 = {
'': 'fab--*',
'.fab__icon': 'fab--*__icon'
};
/**
* @element ons-fab
* @category form
* @description
* [en]
* The Floating action button is a circular button defined in the [Material Design specification](https://www.google.com/design/spec/components/buttons-floating-action-button.html). They are often used to promote the primary action of the app.
*
* It can be displayed either as an inline element or in one of the corners. Normally it will be positioned in the lower right corner of the screen.
* [/en]
* [ja][/ja]
* @tutorial vanilla/Reference/fab
* @modifier mini
* [en]Makes the `ons-fab` smaller.[/en]
* [ja][/ja]
* @guide theming.html#cross-platform-styling-autostyling [en]Information about cross platform styling[/en][ja]Information about cross platform styling[/ja]
* @seealso ons-speed-dial
* [en]The `` component is a Floating action button that displays a menu when tapped.[/en]
* [ja][/ja]
*/
var FabElement = function (_BaseElement) {
inherits(FabElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the button.[/en]
* [ja]ボタンの表現を指定します。[/ja]
*/
/**
* @attribute ripple
* @description
* [en]If this attribute is defined, the button will have a ripple effect when tapped.[/en]
* [ja][/ja]
*/
/**
* @attribute position
* @type {String}
* @description
* [en]The position of the button. Should be a string like `"bottom right"` or `"top left"`. If this attribute is not defined it will be displayed as an inline element.[/en]
* [ja][/ja]
*/
/**
* @attribute disabled
* @description
* [en]Specify if button should be disabled.[/en]
* [ja]ボタンを無効化する場合は指定します。[/ja]
*/
function FabElement() {
classCallCheck(this, FabElement);
// The following statements can be executed before contentReady
// since these do not access the children
var _this = possibleConstructorReturn(this, (FabElement.__proto__ || Object.getPrototypeOf(FabElement)).call(this));
_this._hide();
_this.classList.add(defaultClassName$3);
contentReady(_this, function () {
_this._compile();
});
return _this;
}
createClass(FabElement, [{
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
if (!util$1.findChild(this, '.fab__icon')) {
var content = document.createElement('span');
content.classList.add('fab__icon');
util$1.arrayFrom(this.childNodes).forEach(function (element) {
if (!element.tagName || element.tagName.toLowerCase() !== 'ons-ripple') {
content.appendChild(element);
}
});
this.appendChild(content);
}
this._updateRipple();
ModifierUtil.initModifier(this, scheme$7);
this._updatePosition();
}
}, {
key: 'connectedCallback',
value: function connectedCallback() {
var _this2 = this;
setImmediate(function () {
return _this2._show();
});
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$3, scheme$7);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$7);
break;
case 'ripple':
this._updateRipple();
break;
case 'position':
this._updatePosition();
break;
}
}
}, {
key: '_show',
value: function _show() {
if (!this._manuallyHidden) {
// if user has not called ons-fab.hide()
this._toggle(true);
}
}
}, {
key: '_hide',
value: function _hide() {
var _this3 = this;
setImmediate(function () {
return _this3._toggle(false);
});
}
}, {
key: '_updateRipple',
value: function _updateRipple() {
util$1.updateRipple(this);
}
}, {
key: '_updatePosition',
value: function _updatePosition() {
var position = this.getAttribute('position');
this.classList.remove('fab--top__left', 'fab--bottom__right', 'fab--bottom__left', 'fab--top__right', 'fab--top__center', 'fab--bottom__center');
switch (position) {
case 'top right':
case 'right top':
this.classList.add('fab--top__right');
break;
case 'top left':
case 'left top':
this.classList.add('fab--top__left');
break;
case 'bottom right':
case 'right bottom':
this.classList.add('fab--bottom__right');
break;
case 'bottom left':
case 'left bottom':
this.classList.add('fab--bottom__left');
break;
case 'center top':
case 'top center':
this.classList.add('fab--top__center');
break;
case 'center bottom':
case 'bottom center':
this.classList.add('fab--bottom__center');
break;
default:
break;
}
}
/**
* @method show
* @signature show()
* @description
* [en]Show the floating action button.[/en]
* [ja][/ja]
*/
}, {
key: 'show',
value: function show() {
this.toggle(true);
}
/**
* @method hide
* @signature hide()
* @description
* [en]Hide the floating action button.[/en]
* [ja][/ja]
*/
}, {
key: 'hide',
value: function hide() {
this.toggle(false);
}
/**
* @method toggle
* @signature toggle()
* @description
* [en]Toggle the visibility of the button.[/en]
* [ja][/ja]
*/
}, {
key: 'toggle',
value: function toggle() {
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !this.visible;
this._manuallyHidden = !action;
this._toggle(action);
}
}, {
key: '_toggle',
value: function _toggle() {
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !this.visible;
var isBottom = (this.getAttribute('position') || '').indexOf('bottom') >= 0;
var translate = isBottom ? 'translate3d(0px, -' + (util$1.globals.fabOffset || 0) + 'px, 0px)' : '';
styler(this, { transform: translate + ' scale(' + Number(action) + ')' });
}
/**
* @property disabled
* @type {Boolean}
* @description
* [en]Whether the element is disabled or not.[/en]
* [ja]無効化されている場合に`true`。[/ja]
*/
}, {
key: 'disabled',
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'disabled', value);
},
get: function get$$1() {
return this.hasAttribute('disabled');
}
/**
* @property visible
* @readonly
* @type {Boolean}
* @description
* [en]Whether the element is visible or not.[/en]
* [ja]要素が見える場合に`true`。[/ja]
*/
}, {
key: 'visible',
get: function get$$1() {
return this.style.transform.indexOf('scale(0)') === -1 && this.style.display !== 'none';
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'ripple', 'position', 'class'];
}
}]);
return FabElement;
}(BaseElement);
onsElements.Fab = FabElement;
customElements.define('ons-fab', FabElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-gesture-detector
* @category gesture
* @description
* [en]
* Component to detect finger gestures within the wrapped element. Following gestures are supported:
* - Drag gestures: `drag`, `dragleft`, `dragright`, `dragup`, `dragdown`
* - Hold gestures: `hold`, `release`
* - Swipe gestures: `swipe`, `swipeleft`, `swiperight`, `swipeup`, `swipedown`
* - Tap gestures: `tap`, `doubletap`
* - Pinch gestures: `pinch`, `pinchin`, `pinchout`
* - Other gestures: `touch`, `transform`, `rotate`
* [/en]
* [ja]要素内のジェスチャー操作を検知します。詳しくはガイドを参照してください。[/ja]
* @guide features.html#gesture-detection
* [en]Detecting finger gestures[/en]
* [ja]ジェスチャー操作の検知[/ja]
* @example
*
*
* Swipe Here
*
*
*
*
*/
var GestureDetectorElement = function (_BaseElement) {
inherits(GestureDetectorElement, _BaseElement);
function GestureDetectorElement() {
classCallCheck(this, GestureDetectorElement);
var _this = possibleConstructorReturn(this, (GestureDetectorElement.__proto__ || Object.getPrototypeOf(GestureDetectorElement)).call(this));
_this._gestureDetector = new GestureDetector(_this, { passive: true });
return _this;
}
return GestureDetectorElement;
}(BaseElement);
onsElements.GestureDetector = GestureDetectorElement;
customElements.define('ons-gesture-detector', GestureDetectorElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var autoPrefix = 'fa'; // FIXME: To be removed in v3
/**
* @element ons-icon
* @category visual
* @description
* [en]
* Displays an icon. The following icon suites are available:
*
* * [Font Awesome](https://fortawesome.github.io/Font-Awesome/)
* * [Ionicons](http://ionicons.com/)
* * [Material Design Iconic Font](http://zavoloklom.github.io/material-design-iconic-font/)
* [/en]
* [ja][/ja]
* @codepen xAhvg
* @tutorial vanilla/Reference/icon
* @guide theming.html#cross-platform-styling-autostyling [en]Information about cross platform styling[/en][ja][/ja]
* @guide appsize.html#removing-icon-packs [en]Removing icon packs.[/en][ja][/ja]
* @guide faq.html#how-can-i-use-custom-icon-packs [en]Adding custom icon packs.[/en][ja][/ja]
* @example
*
*
*
*
*
* Car
*
*/
var IconElement = function (_BaseElement) {
inherits(IconElement, _BaseElement);
/**
* @attribute icon
* @type {String}
* @description
* [en]
* The icon name. `"md-"` prefix for Material Icons, `"fa-"` for Font Awesome and `"ion-"` prefix for Ionicons.
*
* See all available icons on the element description (at the top).
*
* Icons can also be styled based on modifier presence. Add comma-separated icons with `"modifierName:"` prefix.
*
* The code `` will display `"md-edit"` for Material Design and `"ion-edit"` as the default icon.
*
* `fa-` prefix is added automatically if none is provided. Check [See also](#seealso) section for more information.
* [/en]
* [ja][/ja]
*/
/**
* @attribute size
* @type {String}
* @description
* [en]
* The sizes of the icon. Valid values are lg, 2x, 3x, 4x, 5x, or in the size in pixels.
* Icons can also be styled based on modifier presence. Add comma-separated icons with `"modifierName:"` prefix.
*
* The code:
*
* ```
*
*
* ```
*
* will render as a `24px` icon if the `"material"` modifier is present and `32px` otherwise.
* [/en]
* [ja][/ja]
*/
/**
* @attribute rotate
* @type {Number}
* @description
* [en]Number of degrees to rotate the icon. Valid values are 90, 180 and 270.[/en]
* [ja]アイコンを回転して表示します。90, 180, 270から指定できます。[/ja]
*/
/**
* @attribute fixed-width
* @type {Boolean}
* @default false
* @description
* [en]When used in a list, you want the icons to have the same width so that they align vertically by defining this attribute.[/en]
* [ja][/ja]
*/
/**
* @attribute spin
* @description
* [en]Specify whether the icon should be spinning.[/en]
* [ja]アイコンを回転するかどうかを指定します。[/ja]
*/
function IconElement() {
classCallCheck(this, IconElement);
var _this = possibleConstructorReturn(this, (IconElement.__proto__ || Object.getPrototypeOf(IconElement)).call(this));
contentReady(_this, function () {
_this._compile();
});
return _this;
}
createClass(IconElement, [{
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
this._cleanClassAttribute(name === 'icon' ? last : this.getAttribute('icon'), name === 'modifier' ? last : undefined);
this._update();
}
}, {
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this._update();
}
}, {
key: '_update',
value: function _update() {
var _this2 = this;
var _buildClassAndStyle2 = this._buildClassAndStyle(this._parseAttr('icon'), this._parseAttr('size')),
classList = _buildClassAndStyle2.classList,
style = _buildClassAndStyle2.style;
util$1.extend(this.style, style);
classList.forEach(function (className) {
return _this2.classList.add(className);
});
}
}, {
key: '_parseAttr',
value: function _parseAttr(attrName) {
var modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getAttribute('modifier') || '';
var attr = this.getAttribute(attrName) || attrName || '';
var parts = attr.split(/\s*,\s*/);
var def = parts[0];
var md = parts[1];
md = (md || '').split(/\s*:\s*/);
return (modifier && RegExp('(^|\\s+)' + md[0] + '($|\\s+)', 'i').test(modifier) ? md[1] : def) || '';
}
/**
* Remove unneeded class value.
*/
}, {
key: '_cleanClassAttribute',
value: function _cleanClassAttribute(lastIcon, lastModifier) {
var _this3 = this;
var _prefixIcon2 = this._prefixIcon(this._parseAttr(lastIcon, lastModifier)),
className = _prefixIcon2.className,
prefix = _prefixIcon2.prefix;
var customPrefixRE = className !== prefix ? '|' + prefix + '$|' + prefix + '-' : '|' + className + '$' || '';
var re = new RegExp('^(fa$|fa-|ion-|zmdi$|zmdi-|ons-icon--' + customPrefixRE + ')');
util$1.arrayFrom(this.classList).filter(function (className) {
return re.test(className);
}).forEach(function (className) {
return _this3.classList.remove(className);
});
}
}, {
key: '_prefixIcon',
value: function _prefixIcon(iconName) {
var className = autoPrefix + (autoPrefix ? '-' : '') + iconName;
return { className: className, prefix: className.split('-')[0] };
}
}, {
key: '_buildClassAndStyle',
value: function _buildClassAndStyle(iconName, size) {
var classList = ['ons-icon'];
var style = {};
// Icon
if (iconName.indexOf('ion-') === 0) {
classList.push(iconName);
classList.push('ons-icon--ion');
} else if (iconName.indexOf('fa-') === 0) {
classList.push(iconName);
// default icon style to Font Awesome Solid if icon style is not specified already
if (!(this.classList.contains('far') || this.classList.contains('fab') || this.classList.contains('fal'))) {
classList.push('fa');
}
} else if (iconName.indexOf('md-') === 0) {
classList.push('zmdi');
classList.push('zmdi-' + iconName.split(/-(.+)?/)[1]);
} else {
var _prefixIcon3 = this._prefixIcon(iconName),
className = _prefixIcon3.className,
prefix = _prefixIcon3.prefix;
prefix && classList.push(prefix);
className && classList.push(className);
}
// Size
if (size.match(/^[1-5]x|lg$/)) {
classList.push('ons-icon--' + size);
this.style.removeProperty('font-size');
} else {
style.fontSize = size;
}
return {
classList: classList,
style: style
};
}
}], [{
key: 'setAutoPrefix',
value: function setAutoPrefix(prefix) {
autoPrefix = prefix ? typeof prefix === 'string' && prefix || 'fa' : '';
}
}, {
key: 'observedAttributes',
get: function get$$1() {
return ['icon', 'size', 'modifier', 'class'];
}
}]);
return IconElement;
}(BaseElement);
onsElements.Icon = IconElement;
customElements.define('ons-icon', IconElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var LazyRepeatDelegate = function () {
function LazyRepeatDelegate(userDelegate) {
var templateElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
classCallCheck(this, LazyRepeatDelegate);
if ((typeof userDelegate === 'undefined' ? 'undefined' : _typeof(userDelegate)) !== 'object' || userDelegate === null) {
util$1.throw('"delegate" parameter must be an object');
}
this._userDelegate = userDelegate;
if (!(templateElement instanceof Element) && templateElement !== null) {
util$1.throw('"templateElement" parameter must be an instance of Element or null');
}
this._templateElement = templateElement;
}
createClass(LazyRepeatDelegate, [{
key: 'hasRenderFunction',
/**
* @return {Boolean}
*/
value: function hasRenderFunction() {
return this._userDelegate._render instanceof Function;
}
/**
* @return {void}
*/
}, {
key: '_render',
value: function _render() {
this._userDelegate._render.apply(this._userDelegate, arguments);
}
/**
* @param {Number} index
* @param {Function} done A function that take item object as parameter.
*/
}, {
key: 'loadItemElement',
value: function loadItemElement(index, done) {
if (this._userDelegate.loadItemElement instanceof Function) {
this._userDelegate.loadItemElement(index, done);
} else {
var element = this._userDelegate.createItemContent(index, this._templateElement);
if (!(element instanceof Element)) {
util$1.throw('"createItemContent" must return an instance of Element');
}
done({ element: element });
}
}
/**
* @return {Number}
*/
}, {
key: 'countItems',
value: function countItems() {
var count = this._userDelegate.countItems();
if (typeof count !== 'number') {
util$1.throw('"countItems" must return a number');
}
return count;
}
/**
* @param {Number} index
* @param {Object} item
* @param {Element} item.element
*/
}, {
key: 'updateItem',
value: function updateItem(index, item) {
if (this._userDelegate.updateItemContent instanceof Function) {
this._userDelegate.updateItemContent(index, item);
}
}
/**
* @return {Number}
*/
}, {
key: 'calculateItemHeight',
value: function calculateItemHeight(index) {
if (this._userDelegate.calculateItemHeight instanceof Function) {
var height = this._userDelegate.calculateItemHeight(index);
if (typeof height !== 'number') {
util$1.throw('"calculateItemHeight" must return a number');
}
return height;
}
return 0;
}
/**
* @param {Number} index
* @param {Object} item
*/
}, {
key: 'destroyItem',
value: function destroyItem(index, item) {
if (this._userDelegate.destroyItem instanceof Function) {
this._userDelegate.destroyItem(index, item);
}
}
/**
* @return {void}
*/
}, {
key: 'destroy',
value: function destroy() {
if (this._userDelegate.destroy instanceof Function) {
this._userDelegate.destroy();
}
this._userDelegate = this._templateElement = null;
}
}, {
key: 'itemHeight',
get: function get$$1() {
return this._userDelegate.itemHeight;
}
}]);
return LazyRepeatDelegate;
}();
/**
* This class provide core functions for ons-lazy-repeat.
*/
var LazyRepeatProvider = function () {
/**
* @param {Element} wrapperElement
* @param {LazyRepeatDelegate} delegate
*/
function LazyRepeatProvider(wrapperElement, delegate) {
classCallCheck(this, LazyRepeatProvider);
if (!(delegate instanceof LazyRepeatDelegate)) {
util$1.throw('"delegate" parameter must be an instance of LazyRepeatDelegate');
}
this._wrapperElement = wrapperElement;
this._delegate = delegate;
this._insertIndex = this._wrapperElement.children[0] && this._wrapperElement.children[0].tagName === 'ONS-LAZY-REPEAT' ? 1 : 0;
if (wrapperElement.tagName.toLowerCase() === 'ons-list') {
wrapperElement.classList.add('lazy-list');
}
this._pageContent = this._findPageContentElement(wrapperElement);
if (!this._pageContent) {
util$1.throw('LazyRepeat must be descendant of a Page element');
}
this.lastScrollTop = this._pageContent.scrollTop;
this.padding = 0;
this._topPositions = [0];
this._renderedItems = {};
if (!this._delegate.itemHeight && !this._delegate.calculateItemHeight(0)) {
this._unknownItemHeight = true;
}
this._addEventListeners();
this._onChange();
}
createClass(LazyRepeatProvider, [{
key: '_findPageContentElement',
value: function _findPageContentElement(wrapperElement) {
var pageContent = util$1.findParent(wrapperElement, '.page__content');
if (pageContent) {
return pageContent;
}
var page = util$1.findParent(wrapperElement, 'ons-page');
if (page) {
var content = util$1.findChild(page, '.content');
if (content) {
return content;
}
}
return null;
}
}, {
key: '_checkItemHeight',
value: function _checkItemHeight(callback) {
var _this = this;
this._delegate.loadItemElement(0, function (item) {
if (!_this._unknownItemHeight) {
util$1.throw('Invalid state');
}
_this._wrapperElement.appendChild(item.element);
var done = function done() {
_this._delegate.destroyItem(0, item);
item.element && item.element.remove();
delete _this._unknownItemHeight;
callback();
};
_this._itemHeight = item.element.offsetHeight;
if (_this._itemHeight > 0) {
done();
return;
}
// retry to measure offset height
// dirty fix for angular2 directive
_this._wrapperElement.style.visibility = 'hidden';
item.element.style.visibility = 'hidden';
setImmediate(function () {
_this._itemHeight = item.element.offsetHeight;
if (_this._itemHeight == 0) {
util$1.throw('Invalid state: "itemHeight" must be greater than zero');
}
_this._wrapperElement.style.visibility = '';
done();
});
});
}
}, {
key: '_countItems',
value: function _countItems() {
return this._delegate.countItems();
}
}, {
key: '_getItemHeight',
value: function _getItemHeight(i) {
// Item is rendered
if (this._renderedItems.hasOwnProperty(i)) {
if (!this._renderedItems[i].hasOwnProperty('height')) {
this._renderedItems[i].height = this._renderedItems[i].element.offsetHeight;
}
return this._renderedItems[i].height;
}
// Item is not rendered, scroll up
if (this._topPositions[i + 1] && this._topPositions[i]) {
return this._topPositions[i + 1] - this._topPositions[i];
}
// Item is not rendered, scroll down
return this.staticItemHeight || this._delegate.calculateItemHeight(i);
}
}, {
key: '_calculateRenderedHeight',
value: function _calculateRenderedHeight() {
var _this2 = this;
return Object.keys(this._renderedItems).reduce(function (a, b) {
return a + _this2._getItemHeight(+b);
}, 0);
}
}, {
key: '_onChange',
value: function _onChange() {
this._render();
}
}, {
key: '_lastItemRendered',
value: function _lastItemRendered() {
return Math.max.apply(Math, toConsumableArray(Object.keys(this._renderedItems)));
}
}, {
key: '_firstItemRendered',
value: function _firstItemRendered() {
return Math.min.apply(Math, toConsumableArray(Object.keys(this._renderedItems)));
}
}, {
key: 'refresh',
value: function refresh() {
var forceRender = { forceScrollDown: true };
var firstItemIndex = this._firstItemRendered();
if (util$1.isInteger(firstItemIndex)) {
this._wrapperElement.style.height = this._topPositions[firstItemIndex] + this._calculateRenderedHeight() + 'px';
this.padding = this._topPositions[firstItemIndex];
forceRender.forceFirstIndex = firstItemIndex;
}
this._removeAllElements();
this._render(forceRender);
this._wrapperElement.style.height = 'inherit';
}
}, {
key: '_render',
value: function _render() {
var _this3 = this;
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$forceScrollDown = _ref.forceScrollDown,
forceScrollDown = _ref$forceScrollDown === undefined ? false : _ref$forceScrollDown,
forceFirstIndex = _ref.forceFirstIndex,
forceLastIndex = _ref.forceLastIndex;
if (this._unknownItemHeight) {
return this._checkItemHeight(this._render.bind(this, arguments[0]));
}
var isScrollUp = !forceScrollDown && this.lastScrollTop > this._pageContent.scrollTop;
this.lastScrollTop = this._pageContent.scrollTop;
var keep = {};
var offset = this._wrapperElement.getBoundingClientRect().top;
var limit = 4 * window.innerHeight - offset;
var count = this._countItems();
var start = forceFirstIndex || Math.max(0, this._calculateStartIndex(offset) - 30); // Recalculate for 0 or undefined
var i = start;
for (var top = this._topPositions[i]; i < count && top < limit; i++) {
if (i >= this._topPositions.length) {
// perf optimization
this._topPositions.length += 100;
}
this._topPositions[i] = top;
top += this._getItemHeight(i);
}
if (this._delegate.hasRenderFunction && this._delegate.hasRenderFunction()) {
return this._delegate._render(start, i, function () {
_this3.padding = _this3._topPositions[start];
});
}
if (isScrollUp) {
for (var j = i - 1; j >= start; j--) {
keep[j] = true;
this._renderElement(j, isScrollUp);
}
} else {
var lastIndex = forceLastIndex || Math.max.apply(Math, [i - 1].concat(toConsumableArray(Object.keys(this._renderedItems)))); // Recalculate for 0 or undefined
for (var _j = start; _j <= lastIndex; _j++) {
keep[_j] = true;
this._renderElement(_j, isScrollUp);
}
}
Object.keys(this._renderedItems).forEach(function (key) {
return keep[key] || _this3._removeElement(key, isScrollUp);
});
}
/**
* @param {Number} index
* @param {Boolean} isScrollUp
*/
}, {
key: '_renderElement',
value: function _renderElement(index, isScrollUp) {
var _this4 = this;
var item = this._renderedItems[index];
if (item) {
this._delegate.updateItem(index, item); // update if it exists
return;
}
this._delegate.loadItemElement(index, function (item) {
if (isScrollUp) {
_this4._wrapperElement.insertBefore(item.element, _this4._wrapperElement.children[_this4._insertIndex]);
_this4.padding = _this4._topPositions[index];
item.height = _this4._topPositions[index + 1] - _this4._topPositions[index];
} else {
_this4._wrapperElement.appendChild(item.element);
}
_this4._renderedItems[index] = item;
});
}
/**
* @param {Number} index
* @param {Boolean} isScrollUp
*/
}, {
key: '_removeElement',
value: function _removeElement(index) {
var isScrollUp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
index = +index;
var item = this._renderedItems[index];
this._delegate.destroyItem(index, item);
if (isScrollUp) {
this._topPositions[index + 1] = undefined;
} else {
this.padding = this.padding + this._getItemHeight(index);
}
if (item.element.parentElement) {
item.element.parentElement.removeChild(item.element);
}
delete this._renderedItems[index];
}
}, {
key: '_removeAllElements',
value: function _removeAllElements() {
var _this5 = this;
Object.keys(this._renderedItems).forEach(function (key) {
return _this5._removeElement(key);
});
}
}, {
key: '_recalculateTopPositions',
value: function _recalculateTopPositions(start, end) {
for (var i = start; i <= end; i++) {
this._topPositions[i + 1] = this._topPositions[i] + this._getItemHeight(i);
}
}
}, {
key: '_calculateStartIndex',
value: function _calculateStartIndex(current) {
var firstItemIndex = this._firstItemRendered();
var lastItemIndex = this._lastItemRendered();
// Fix for Safari scroll and Angular 2
this._recalculateTopPositions(firstItemIndex, lastItemIndex);
var start = 0;
var end = this._countItems() - 1;
// Binary search for index at top of screen so we can speed up rendering.
for (;;) {
var middle = Math.floor((start + end) / 2);
var value = current + this._topPositions[middle];
if (end < start) {
return 0;
} else if (value <= 0 && value + this._getItemHeight(middle) > 0) {
return middle;
} else if (isNaN(value) || value >= 0) {
end = middle - 1;
} else {
start = middle + 1;
}
}
}
}, {
key: '_debounce',
value: function _debounce(func, wait, immediate) {
var timeout = void 0;
return function () {
var _this6 = this,
_arguments = arguments;
var callNow = immediate && !timeout;
clearTimeout(timeout);
if (callNow) {
func.apply(this, arguments);
} else {
timeout = setTimeout(function () {
timeout = null;
func.apply(_this6, _arguments);
}, wait);
}
};
}
}, {
key: '_doubleFireOnTouchend',
value: function _doubleFireOnTouchend() {
this._render();
this._debounce(this._render.bind(this), 100);
}
}, {
key: '_addEventListeners',
value: function _addEventListeners() {
util$1.bindListeners(this, ['_onChange', '_doubleFireOnTouchend']);
if (platform.isIOS()) {
this._boundOnChange = this._debounce(this._boundOnChange, 30);
}
this._pageContent.addEventListener('scroll', this._boundOnChange, true);
if (platform.isIOS()) {
util$1.addEventListener(this._pageContent, 'touchmove', this._boundOnChange, { capture: true, passive: true });
this._pageContent.addEventListener('touchend', this._boundDoubleFireOnTouchend, true);
}
window.document.addEventListener('resize', this._boundOnChange, true);
}
}, {
key: '_removeEventListeners',
value: function _removeEventListeners() {
this._pageContent.removeEventListener('scroll', this._boundOnChange, true);
if (platform.isIOS()) {
util$1.removeEventListener(this._pageContent, 'touchmove', this._boundOnChange, { capture: true, passive: true });
this._pageContent.removeEventListener('touchend', this._boundDoubleFireOnTouchend, true);
}
window.document.removeEventListener('resize', this._boundOnChange, true);
}
}, {
key: 'destroy',
value: function destroy() {
this._removeAllElements();
this._delegate.destroy();
this._parentElement = this._delegate = this._renderedItems = null;
this._removeEventListeners();
}
}, {
key: 'padding',
get: function get$$1() {
return parseInt(this._wrapperElement.style.paddingTop, 10);
},
set: function set$$1(newValue) {
this._wrapperElement.style.paddingTop = newValue + 'px';
}
}, {
key: 'staticItemHeight',
get: function get$$1() {
return this._delegate.itemHeight || this._itemHeight;
}
}]);
return LazyRepeatProvider;
}();
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @element ons-lazy-repeat
* @category list
* @description
* [en]
* Using this component a list with millions of items can be rendered without a drop in performance.
* It does that by "lazily" loading elements into the DOM when they come into view and
* removing items from the DOM when they are not visible.
* [/en]
* [ja]
* このコンポーネント内で描画されるアイテムのDOM要素の読み込みは、画面に見えそうになった時まで自動的に遅延され、
* 画面から見えなくなった場合にはその要素は動的にアンロードされます。
* このコンポーネントを使うことで、パフォーマンスを劣化させること無しに巨大な数の要素を描画できます。
* [/ja]
* @codepen QwrGBm
* @tutorial vanilla/Reference/lazy-repeat
* @seealso ons-list
* [en]The `` element is used to render a list.[/en]
* [ja]``要素はリストを描画するのに使われます。[/ja]
* @example
*
*
*
*
*
*
*
*/
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() {
// not very good idea and also not documented
if (this.hasAttribute('delegate')) {
this.delegate = window[this.getAttribute('delegate')];
}
}
/**
* @property delegate
* @type {Object}
* @description
* [en]Specify a delegate object to load and unload item elements.[/en]
* [ja]要素のロード、アンロードなどの処理を委譲するオブジェクトを指定します。[/ja]
*/
/**
* @property delegate.createItemContent
* @type {Function}
* @description
* [en]
* This function should return a `HTMLElement`.
*
* To help rendering the element, the current index and a template is supplied as arguments. The template is the initial content of the `` element.
* [/en]
* [ja]
* この関数は`HTMLElement`を返してください。
* 要素を生成しやすくするために、現在のアイテムのインデックスとテンプレートが引数に渡されます。
* このテンプレートは、``要素のコンテンツが渡されます。
* [/ja]
*/
/**
* @property delegate.countItems
* @type {Function}
* @description
* [en]Should return the number of items in the list.[/en]
* [ja]リスト内のアイテム数を返してください。[/ja]
*/
/**
* @property delegate.calculateItemHeight
* @type {Function}
* @description
* [en]
* Should return the height of an item. The index is provided as an argument.
*
* This is important when rendering lists where the items have different height.
*
* The function is optional and if it isn't present the height of the first item will be automatically calculated and used for all other items.
* [/en]
* [ja]
* アイテムの高さ(ピクセル)を返してください。アイテムのインデックス値は引数で渡されます。
* この関数は、それぞれのアイムが違った高さを持つリストをレンダリングする際に重要です。
* この関数はオプショナルです。もしこの関数が無い場合には、
* 最初のアイテムの高さが他のすべてのアイテムの高さとして利用されます。
* [/ja]
*/
/**
* @property delegate.destroyItem
* @type {Function}
* @description
* [en]
* This function is used called when an item is removed from the DOM. The index and DOM element is provided as arguments.
*
* The function is optional but may be important in order to avoid memory leaks.
* [/en]
* [ja]
* この関数は、あるアイテムがDOMツリーから除かれた時に呼び出されます。
* アイテムのインデックス値とDOM要素が引数として渡されます。
* この関数はオプショナルですが、各アイテムの後処理が必要な場合にはメモリーリークを避けるために重要です。
* [/ja]
*/
}, {
key: 'refresh',
/**
* @method refresh
* @signature refresh()
* @description
* [en]Refresh the list. Use this method when the data has changed.[/en]
* [ja]リストを更新します。もしデータが変わった場合にはこのメソッドを使ってください。[/ja]
*/
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$$1(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$$1() {
util$1.throw('No delegate getter');
}
}]);
return LazyRepeatElement;
}(BaseElement);
internal$1.LazyRepeatDelegate = LazyRepeatDelegate;
internal$1.LazyRepeatProvider = LazyRepeatProvider;
onsElements.LazyRepeat = LazyRepeatElement;
customElements.define('ons-lazy-repeat', LazyRepeatElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$4 = 'list-header';
var scheme$8 = { '': 'list-header--*' };
/**
* @element ons-list-header
* @category list
* @description
* [en]Header element for list items. Must be put inside the `` component.[/en]
* [ja]リスト要素に使用するヘッダー用コンポーネント。ons-listと共に使用します。[/ja]
* @seealso ons-list
* [en]The `` component[/en]
* [ja]ons-listコンポーネント[/ja]
* @seealso ons-list-item
* [en]The `` component[/en]
* [ja]ons-list-itemコンポーネント[/ja]
* @codepen yxcCt
* @tutorial vanilla/Reference/list
* @modifier material
* [en]Display a Material Design list header.[/en]
* [ja][/ja]
* @example
*
* Header Text
* Item
* Item
*
*/
var ListHeaderElement = function (_BaseElement) {
inherits(ListHeaderElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the list header.[/en]
* [ja]ヘッダーの表現を指定します。[/ja]
*/
function ListHeaderElement() {
classCallCheck(this, ListHeaderElement);
var _this = possibleConstructorReturn(this, (ListHeaderElement.__proto__ || Object.getPrototypeOf(ListHeaderElement)).call(this));
_this._compile();
return _this;
}
createClass(ListHeaderElement, [{
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.classList.add(defaultClassName$4);
ModifierUtil.initModifier(this, scheme$8);
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$4, scheme$8);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$8);
break;
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class'];
}
}]);
return ListHeaderElement;
}(BaseElement);
onsElements.ListHeader = ListHeaderElement;
customElements.define('ons-list-header', ListHeaderElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$5 = 'list-title';
var scheme$9 = { '': 'list-title--*' };
/**
* @element ons-list-title
* @category list
* @description
* [en]Represents a list title.[/en]
* [ja]リストのタイトルを表現します。[/ja]
* @example
* List Title
*
* Item
*
* @modifier material
* [en]Display a Material Design list title.[/en]
* [ja][/ja]
*/
var ListTitleElement = function (_BaseElement) {
inherits(ListTitleElement, _BaseElement);
function ListTitleElement() {
classCallCheck(this, ListTitleElement);
var _this = possibleConstructorReturn(this, (ListTitleElement.__proto__ || Object.getPrototypeOf(ListTitleElement)).call(this));
_this._compile();
return _this;
}
createClass(ListTitleElement, [{
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.classList.add(defaultClassName$5);
ModifierUtil.initModifier(this, scheme$9);
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$5, scheme$9);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$9);
break;
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class'];
}
}]);
return ListTitleElement;
}(BaseElement);
onsElements.ListTitle = ListTitleElement;
customElements.define('ons-list-title', ListTitleElement);
/*
Copyright 2013-2018 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var ListItemAnimator = function (_BaseAnimator) {
inherits(ListItemAnimator, _BaseAnimator);
function ListItemAnimator() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$timing = _ref.timing,
timing = _ref$timing === undefined ? 'linear' : _ref$timing,
_ref$delay = _ref.delay,
delay = _ref$delay === undefined ? 0 : _ref$delay,
_ref$duration = _ref.duration,
duration = _ref$duration === undefined ? 0.2 : _ref$duration;
classCallCheck(this, ListItemAnimator);
return possibleConstructorReturn(this, (ListItemAnimator.__proto__ || Object.getPrototypeOf(ListItemAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
}
createClass(ListItemAnimator, [{
key: 'showExpansion',
value: function showExpansion(listItem, callback) {
callback();
}
}, {
key: 'hideExpansion',
value: function hideExpansion(listItem, callback) {
callback();
}
}]);
return ListItemAnimator;
}(BaseAnimator);
var SlideListItemAnimator = function (_ListItemAnimator) {
inherits(SlideListItemAnimator, _ListItemAnimator);
function SlideListItemAnimator() {
classCallCheck(this, SlideListItemAnimator);
return possibleConstructorReturn(this, (SlideListItemAnimator.__proto__ || Object.getPrototypeOf(SlideListItemAnimator)).apply(this, arguments));
}
createClass(SlideListItemAnimator, [{
key: 'showExpansion',
value: function showExpansion(listItem, callback) {
this._animateExpansion(listItem, true, callback);
}
}, {
key: 'hideExpansion',
value: function hideExpansion(listItem, callback) {
this._animateExpansion(listItem, false, callback);
}
}, {
key: '_animateExpansion',
value: function _animateExpansion(listItem, shouldOpen, callback) {
var _animit;
// To animate the opening of the expansion panel correctly, we need to know its
// height. To calculate this, we set its height to auto, and then get the computed
// height and padding. Once this is done, we set the height back to its original value.
var oldHeight = listItem.expandableContent.style.height;
var oldDisplay = listItem.expandableContent.style.display;
listItem.expandableContent.style.height = 'auto';
listItem.expandableContent.style.display = 'block';
var computedStyle = window.getComputedStyle(listItem.expandableContent);
var expansionOpenTransition = [{ height: 0, paddingTop: 0, paddingBottom: 0 }, {
height: computedStyle.height,
paddingTop: computedStyle.paddingTop,
paddingBottom: computedStyle.paddingBottom
}];
var iconOpenTransition = [{ transform: 'rotate(45deg)' }, { transform: 'rotate(225deg)' }];
// Now that we have the values we need, reset the height back to its original state
listItem.expandableContent.style.height = oldHeight;
(_animit = Animit(listItem.expandableContent, { duration: this.duration, property: 'height padding-top padding-bottom' })).default.apply(_animit, toConsumableArray(shouldOpen ? expansionOpenTransition : expansionOpenTransition.reverse())).play(function () {
listItem.expandableContent.style.display = oldDisplay;
callback && callback();
});
if (listItem.expandChevron) {
var _animit2;
(_animit2 = Animit(listItem.expandChevron, { duration: this.duration, property: 'transform' })).default.apply(_animit2, toConsumableArray(shouldOpen ? iconOpenTransition : iconOpenTransition.reverse())).play();
}
}
}]);
return SlideListItemAnimator;
}(ListItemAnimator);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$6 = 'list-item';
var scheme$10 = {
'.list-item': 'list-item--*',
'.list-item__left': 'list-item--*__left',
'.list-item__center': 'list-item--*__center',
'.list-item__right': 'list-item--*__right',
'.list-item__label': 'list-item--*__label',
'.list-item__title': 'list-item--*__title',
'.list-item__subtitle': 'list-item--*__subtitle',
'.list-item__thumbnail': 'list-item--*__thumbnail',
'.list-item__icon': 'list-item--*__icon'
};
var _animatorDict$3 = {
'default': SlideListItemAnimator,
'none': ListItemAnimator
};
/**
* @element ons-list-item
* @category list
* @modifier tappable
* [en]Make the list item change appearance when it's tapped. On iOS it is better to use the "tappable" and "tap-background-color" attribute for better behavior when scrolling.[/en]
* [ja]タップやクリックした時に効果が表示されるようになります。[/ja]
* @modifier chevron
* [en]Display a chevron at the right end of the list item and make it change appearance when tapped.[/en]
* [ja][/ja]
* @modifier longdivider
* [en]Displays a long horizontal divider between items.[/en]
* [ja][/ja]
* @modifier nodivider
* [en]Removes the divider between list items.[/en]
* [ja][/ja]
* @modifier material
* [en]Display a Material Design list item.[/en]
* [ja][/ja]
* @description
* [en]
* Component that represents each item in a list. The list item is composed of four parts that are represented with the `left`, `center`, `right` and `expandable-content` classes. These classes can be used to ensure that the content of the list items is properly aligned.
*
* ```
*
*
Left
*
Center
*
Right
*
Expandable content
*
* ```
*
* There are also a number of classes (prefixed with `list-item__*`) that help when putting things like icons and thumbnails into the list items.
* [/en]
* [ja][/ja]
* @seealso ons-list
* [en]ons-list component[/en]
* [ja]ons-listコンポーネント[/ja]
* @seealso ons-list-header
* [en]ons-list-header component[/en]
* [ja]ons-list-headerコンポーネント[/ja]
* @codepen yxcCt
* @tutorial vanilla/Reference/list
* @example
*
*
*
*
*
*
Title
*
Subtitle
*
*
*
*
*
*/
var ListItemElement = function (_BaseElement) {
inherits(ListItemElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the list item.[/en]
* [ja]各要素の表現を指定します。[/ja]
*/
/**
* @attribute lock-on-drag
* @type {String}
* @description
* [en]Prevent vertical scrolling when the user drags horizontally.[/en]
* [ja]この属性があると、ユーザーがこの要素を横方向にドラッグしている時に、縦方向のスクロールが起きないようになります。[/ja]
*/
/**
* @attribute tappable
* @type {Boolean}
* @description
* [en]Makes the element react to taps. `prevent-tap` attribute can be added to child elements like buttons or inputs to prevent this effect. `ons-*` elements are ignored by default.[/en]
* [ja][/ja]
*/
/**
* @attribute tap-background-color
* @type {Color}
* @description
* [en] Changes the background color when tapped. For this to work, the attribute "tappable" needs to be set. The default color is "#d9d9d9". It will display as a ripple effect on Android.[/en]
* [ja][/ja]
*/
/**
* @attribute expandable
* @type {Boolean}
* @description
* [en]Makes the element able to be expanded to reveal extra content. For this to work, the expandable content must be defined in `div.expandable-content`.[/en]
* [ja][/ja]
*/
/**
* @attribute animation
* @type {String}
* @default default
* @description
* [en]The animation used when showing and hiding the expandable content. Can be either `"default"` or `"none"`.[/en]
* [ja][/ja]
*/
function ListItemElement() {
classCallCheck(this, ListItemElement);
var _this = possibleConstructorReturn(this, (ListItemElement.__proto__ || Object.getPrototypeOf(ListItemElement)).call(this));
_this._animatorFactory = _this._updateAnimatorFactory();
_this.toggleExpansion = _this.toggleExpansion.bind(_this);
// Elements ignored when tapping
var re = /^ons-(?!col$|row$|if$)/i;
_this._shouldIgnoreTap = function (e) {
return e.hasAttribute('prevent-tap') || re.test(e.tagName);
};
// show and hide functions for Vue hidable mixin
_this.show = _this.showExpansion;
_this.hide = _this.hideExpansion;
contentReady(_this, function () {
_this._compile();
});
return _this;
}
/**
* Compiles the list item.
*
* Various elements are allowed in the body of a list item:
*
* - div.left, div.right, and div.center are allowed as direct children
* - if div.center is not defined, anything that isn't div.left, div.right or div.expandable-content will be put in a div.center
* - if div.center is defined, anything that isn't div.left, div.right or div.expandable-content will be ignored
* - if list item has expandable attribute:
* - div.expandable-content is allowed as a direct child
* - div.top is allowed as direct child
* - if div.top is defined, anything that isn't div.expandable-content should be inside div.top - anything else will be ignored
* - if div.right is not defined, a div.right will be created with a drop-down chevron
*
* See the tests for examples.
*/
createClass(ListItemElement, [{
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.classList.add(defaultClassName$6);
var top = void 0,
expandableContent = void 0;
var topContent = [];
Array.from(this.childNodes).forEach(function (node) {
if (node.nodeType !== Node.ELEMENT_NODE) {
topContent.push(node);
} else if (node.classList.contains('top')) {
top = node;
} else if (node.classList.contains('expandable-content')) {
expandableContent = node;
} else {
topContent.push(node);
}
if (node.nodeName !== 'ONS-RIPPLE') {
node.remove();
}
});
topContent = top ? Array.from(top.childNodes) : topContent;
var left = void 0,
right = void 0,
center = void 0;
var centerContent = [];
topContent.forEach(function (node) {
if (node.nodeType !== Node.ELEMENT_NODE) {
centerContent.push(node);
} else if (node.classList.contains('left')) {
left = node;
} else if (node.classList.contains('right')) {
right = node;
} else if (node.classList.contains('center')) {
center = node;
} else {
centerContent.push(node);
}
});
if (this.hasAttribute('expandable')) {
this.classList.add('list-item--expandable');
if (!top) {
top = document.createElement('div');
top.classList.add('top');
}
top.classList.add('list-item__top');
this.appendChild(top);
this._top = top;
if (expandableContent) {
expandableContent.classList.add('list-item__expandable-content');
this.appendChild(expandableContent);
}
if (!right) {
right = document.createElement('div');
right.classList.add('list-item__right', 'right');
// We cannot use a pseudo-element for this chevron, as we cannot animate it using
// JS. So, we make a chevron span instead.
var chevron = document.createElement('span');
chevron.classList.add('list-item__expand-chevron');
right.appendChild(chevron);
}
} else {
top = this;
}
if (!center) {
center = document.createElement('div');
center.classList.add('center');
centerContent.forEach(function (node) {
return center.appendChild(node);
});
}
center.classList.add('list-item__center');
top.appendChild(center);
if (left) {
left.classList.add('list-item__left');
top.appendChild(left);
}
if (right) {
right.classList.add('list-item__right');
top.appendChild(right);
}
util$1.updateRipple(this);
ModifierUtil.initModifier(this, scheme$10);
}
/**
* @method showExpansion
* @signature showExpansion()
* @description
* [en]Show the expandable content if the element is expandable.[/en]
* [ja][/ja]
*/
}, {
key: 'showExpansion',
value: function showExpansion() {
var _this2 = this;
if (this.hasAttribute('expandable') && !this._expanding) {
this.expanded = true;
this._expanding = true;
var animator = this._animatorFactory.newAnimator();
animator.showExpansion(this, function () {
_this2.classList.add('expanded');
_this2._expanding = false;
});
}
}
/**
* @method hideExpansion
* @signature hideExpansion()
* @description
* [en]Hide the expandable content if the element expandable.[/en]
* [ja][/ja]
*/
}, {
key: 'hideExpansion',
value: function hideExpansion() {
var _this3 = this;
if (this.hasAttribute('expandable') && !this._expanding) {
this.expanded = false;
this._expanding = true;
var animator = this._animatorFactory.newAnimator();
animator.hideExpansion(this, function () {
_this3.classList.remove('expanded');
_this3._expanding = false;
});
}
}
}, {
key: 'toggleExpansion',
value: function toggleExpansion() {
this.classList.contains('expanded') ? this.hideExpansion() : this.showExpansion();
this.dispatchEvent(new Event('expansion'));
}
}, {
key: '_updateAnimatorFactory',
value: function _updateAnimatorFactory() {
return new AnimatorFactory({
animators: _animatorDict$3,
baseClass: ListItemAnimator,
baseClassName: 'ListItemAnimator',
defaultAnimation: this.getAttribute('animation') || 'default'
});
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$6, scheme$10);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$10);
break;
case 'ripple':
util$1.updateRipple(this);
break;
case 'animation':
this._animatorFactory = this._updateAnimatorFactory();
break;
}
}
}, {
key: 'connectedCallback',
value: function connectedCallback() {
var _this4 = this;
contentReady(this, function () {
_this4._setupListeners(true);
_this4._originalBackgroundColor = _this4.style.backgroundColor;
_this4.tapped = false;
});
}
}, {
key: 'disconnectedCallback',
value: function disconnectedCallback() {
this._setupListeners(false);
}
}, {
key: '_setupListeners',
value: function _setupListeners(add) {
var action = (add ? 'add' : 'remove') + 'EventListener';
util$1[action](this, 'touchstart', this._onTouch, { passive: true });
util$1[action](this, 'touchmove', this._onRelease, { passive: true });
this[action]('touchcancel', this._onRelease);
this[action]('touchend', this._onRelease);
this[action]('touchleave', this._onRelease);
this[action]('drag', this._onDrag);
this[action]('mousedown', this._onTouch);
this[action]('mouseup', this._onRelease);
this[action]('mouseout', this._onRelease);
if (this._top) {
this._top[action]('click', this.toggleExpansion);
}
}
}, {
key: '_onDrag',
value: function _onDrag(event) {
var gesture = event.gesture;
// Prevent vertical scrolling if the users pans left or right.
if (this.hasAttribute('lock-on-drag') && ['left', 'right'].indexOf(gesture.direction) > -1) {
gesture.preventDefault();
}
}
}, {
key: '_onTouch',
value: function _onTouch(e) {
var _this5 = this;
if (this.tapped || this !== e.target && (this._shouldIgnoreTap(e.target) || util$1.findParent(e.target, this._shouldIgnoreTap, function (p) {
return p === _this5;
}))) {
return; // Ignore tap
}
this.tapped = true;
var touchStyle = { transition: 'background-color 0.0s linear 0.02s, box-shadow 0.0s linear 0.02s' };
if (this.hasAttribute('tappable')) {
if (this.style.backgroundColor) {
this._originalBackgroundColor = this.style.backgroundColor;
}
touchStyle.backgroundColor = this.getAttribute('tap-background-color') || '#d9d9d9';
touchStyle.boxShadow = '0px -1px 0px 0px ' + touchStyle.backgroundColor;
}
styler(this, touchStyle);
}
}, {
key: '_onRelease',
value: function _onRelease() {
this.tapped = false;
this.style.backgroundColor = this._originalBackgroundColor || '';
styler.clear(this, 'transition boxShadow');
}
}, {
key: 'expandableContent',
get: function get$$1() {
return this.querySelector('.list-item__expandable-content');
}
}, {
key: 'expandChevron',
get: function get$$1() {
return this.querySelector('.list-item__expand-chevron');
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class', 'ripple', 'animation'];
}
}]);
return ListItemElement;
}(BaseElement);
onsElements.ListItem = ListItemElement;
customElements.define('ons-list-item', ListItemElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var defaultClassName$7 = 'list';
var scheme$11 = { '': 'list--*' };
/**
* @element ons-list
* @category list
* @modifier inset
* [en]Inset list that doesn't cover the whole width of the parent.[/en]
* [ja]親要素の画面いっぱいに広がらないリストを表示します。[/ja]
* @modifier noborder
* [en]A list with no borders at the top and bottom.[/en]
* [ja]リストの上下のボーダーが無いリストを表示します。[/ja]
* @description
* [en]Component to define a list, and the container for ons-list-item(s).[/en]
* [ja]リストを表現するためのコンポーネント。ons-list-itemのコンテナとして使用します。[/ja]
* @seealso ons-list-item
* [en]ons-list-item component[/en]
* [ja]ons-list-itemコンポーネント[/ja]
* @seealso ons-list-header
* [en]ons-list-header component[/en]
* [ja]ons-list-headerコンポーネント[/ja]
* @seealso ons-lazy-repeat
* [en]ons-lazy-repeat component[/en]
* [ja]ons-lazy-repeatコンポーネント[/ja]
* @codepen yxcCt
* @tutorial vanilla/Reference/list
* @example
*
* Header Text
* Item
* Item
*
*/
var ListElement = function (_BaseElement) {
inherits(ListElement, _BaseElement);
/**
* @attribute modifier
* @type {String}
* @description
* [en]The appearance of the list.[/en]
* [ja]リストの表現を指定します。[/ja]
*/
function ListElement() {
classCallCheck(this, ListElement);
var _this = possibleConstructorReturn(this, (ListElement.__proto__ || Object.getPrototypeOf(ListElement)).call(this));
_this._compile();
return _this;
}
createClass(ListElement, [{
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this.classList.add(defaultClassName$7);
ModifierUtil.initModifier(this, scheme$11);
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
switch (name) {
case 'class':
util$1.restoreClass(this, defaultClassName$7, scheme$11);
break;
case 'modifier':
ModifierUtil.onModifierChanged(last, current, this, scheme$11);
break;
}
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'class'];
}
}]);
return ListElement;
}(BaseElement);
onsElements.List = ListElement;
customElements.define('ons-list', ListElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var INPUT_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'autocorrect', 'autofocus', 'disabled', 'inputmode', 'max', 'maxlength', 'min', 'minlength', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'size', 'step', 'validator', 'value'];
var BaseInputElement = function (_BaseElement) {
inherits(BaseInputElement, _BaseElement);
createClass(BaseInputElement, [{
key: '_update',
value: function _update() {} // Optionally implemented
}, {
key: '_scheme',
get: function get$$1() {
util$1.throwMember();
}
}, {
key: '_template',
get: function get$$1() {
util$1.throwMember();
}
}, {
key: 'type',
get: function get$$1() {
util$1.throwMember();
}
}]);
function BaseInputElement() {
classCallCheck(this, BaseInputElement);
var _this = possibleConstructorReturn(this, (BaseInputElement.__proto__ || Object.getPrototypeOf(BaseInputElement)).call(this));
if (_this.constructor === BaseInputElement) {
util$1.throwAbstract();
}
contentReady(_this, function () {
return _this._compile();
});
_this._boundDelegateEvent = _this._delegateEvent.bind(_this);
return _this;
}
createClass(BaseInputElement, [{
key: '_compile',
value: function _compile() {
autoStyle.prepare(this);
this._defaultClassName && this.classList.add(this._defaultClassName);
if (this.children.length !== 0) {
return;
}
this.appendChild(util$1.createFragment(this._template));
this._setInputId();
this._updateBoundAttributes();
ModifierUtil.initModifier(this, this._scheme);
}
}, {
key: '_updateBoundAttributes',
value: function _updateBoundAttributes() {
var _this2 = this;
INPUT_ATTRIBUTES.forEach(function (attr) {
if (_this2.hasAttribute(attr)) {
_this2._input.setAttribute(attr, _this2.getAttribute(attr));
} else {
_this2._input.removeAttribute(attr);
}
});
this._update();
}
}, {
key: '_delegateEvent',
value: function _delegateEvent(event) {
var e = new CustomEvent(event.type, {
bubbles: false,
cancelable: true
});
return this.dispatchEvent(e);
}
}, {
key: '_setInputId',
value: function _setInputId() {
if (this.hasAttribute('input-id')) {
this._input.id = this.getAttribute('input-id');
}
}
}, {
key: 'connectedCallback',
value: function connectedCallback() {
var _this3 = this;
contentReady(this, function () {
_this3._input.addEventListener('focus', _this3._boundDelegateEvent);
_this3._input.addEventListener('blur', _this3._boundDelegateEvent);
});
}
}, {
key: 'disconnectedCallback',
value: function disconnectedCallback() {
var _this4 = this;
contentReady(this, function () {
_this4._input.removeEventListener('focus', _this4._boundDelegateEvent);
_this4._input.removeEventListener('blur', _this4._boundDelegateEvent);
});
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
var _this5 = this;
switch (name) {
case 'modifier':
contentReady(this, function () {
return ModifierUtil.onModifierChanged(last, current, _this5, _this5._scheme);
});
break;
case 'input-id':
contentReady(this, function () {
return _this5._setInputId();
});
break;
case 'class':
util$1.restoreClass(this, this._defaultClassName, this._scheme);
break;
}
if (INPUT_ATTRIBUTES.indexOf(name) >= 0) {
contentReady(this, function () {
return _this5._updateBoundAttributes();
});
}
}
}, {
key: '_defaultClassName',
get: function get$$1() {
return '';
}
}, {
key: '_input',
get: function get$$1() {
return this.querySelector('input');
}
}, {
key: 'value',
get: function get$$1() {
return this._input === null ? this.getAttribute('value') : this._input.value;
},
set: function set$$1(val) {
var _this6 = this;
contentReady(this, function () {
if (val instanceof Date) {
val = val.toISOString().substring(0, 10);
}
_this6._input.value = val;
_this6._update();
});
}
}, {
key: 'disabled',
set: function set$$1(value) {
return util$1.toggleAttribute(this, 'disabled', value);
},
get: function get$$1() {
return this.hasAttribute('disabled');
}
}], [{
key: 'observedAttributes',
get: function get$$1() {
return ['modifier', 'input-id', 'class'].concat(INPUT_ATTRIBUTES);
}
}]);
return BaseInputElement;
}(BaseElement);
/*
Copyright 2013-2015 ASIAL CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var scheme$12 = {
'.text-input': 'text-input--*',
'.text-input__label': 'text-input--*__label'
};
/**
* @element ons-input
* @category form
* @modifier material
* [en]Displays a Material Design input.[/en]
* [ja][/ja]
* @modifier underbar
* [en]Displays a horizontal line underneath a text input.[/en]
* [ja][/ja]
* @modifier transparent
* [en]Displays a transparent input. Works for Material Design.[/en]
* [ja][/ja]
* @description
* [en]
* An input element. The `type` attribute can be used to change the input type. All text input types are supported.
*
* The component will automatically render as a Material Design input on Android devices.
*
* Most attributes that can be used for a normal `` element can also be used on the `` element.
* [/en]
* [ja][/ja]
* @tutorial vanilla/Reference/input
* @seealso ons-checkbox
* [en]The `` element is used to display a checkbox.[/en]
* [ja][/ja]
* @seealso ons-radio
* [en]The `` element is used to display a radio button.[/en]
* [ja][/ja]
* @seealso ons-range
* [en]The `` element is used to display a range slider.[/en]
* [ja][/ja]
* @seealso ons-switch
* [en]The `` element is used to display a draggable toggle switch.[/en]
* [ja][/ja]
* @seealso ons-select
* [en]The `` element is used to display a select box.[/en]
* [ja][/ja]
* @guide theming.html#modifiers [en]More details about the `modifier` attribute[/en][ja]modifier属性の使い方[/ja]
* @example
*
*/
var InputElement = function (_BaseInputElement) {
inherits(InputElement, _BaseInputElement);
function InputElement() {
classCallCheck(this, InputElement);
var _this = possibleConstructorReturn(this, (InputElement.__proto__ || Object.getPrototypeOf(InputElement)).call(this));
_this._boundOnInput = _this._update.bind(_this);
_this._boundOnFocusin = _this._update.bind(_this);
return _this;
}
/* Inherited props */
createClass(InputElement, [{
key: '_update',
value: function _update() {
this._updateLabel();
this._updateLabelClass();
}
}, {
key: '_updateLabel',
/* Own props */
value: function _updateLabel() {
var label = this.getAttribute('placeholder') || '';
if (typeof this._helper.textContent !== 'undefined') {
this._helper.textContent = label;
} else {
this._helper.innerText = label;
}
}
}, {
key: '_updateLabelClass',
value: function _updateLabelClass() {
if (this.value === '') {
this._helper.classList.remove('text-input--material__label--active');
} else {
this._helper.classList.add('text-input--material__label--active');
}
}
}, {
key: 'connectedCallback',
value: function connectedCallback() {
var _this2 = this;
get(InputElement.prototype.__proto__ || Object.getPrototypeOf(InputElement.prototype), 'connectedCallback', this).call(this);
contentReady(this, function () {
_this2._input.addEventListener('input', _this2._boundOnInput);
_this2._input.addEventListener('focusin', _this2._boundOnFocusin);
});
var type = this.getAttribute('type');
if (['checkbox', 'radio'].indexOf(type) >= 0) {
util$1.warn('Warn: is deprecated since v2.4.0. Use instead.');
}
}
}, {
key: 'disconnectedCallback',
value: function disconnectedCallback() {
var _this3 = this;
get(InputElement.prototype.__proto__ || Object.getPrototypeOf(InputElement.prototype), 'disconnectedCallback', this).call(this);
contentReady(this, function () {
_this3._input.removeEventListener('input', _this3._boundOnInput);
_this3._input.removeEventListener('focusin', _this3._boundOnFocusin);
});
}
}, {
key: 'attributeChangedCallback',
value: function attributeChangedCallback(name, last, current) {
var _this4 = this;
switch (name) {
case 'type':
contentReady(this, function () {
return _this4._input.setAttribute('type', _this4.type);
});
break;
default:
get(InputElement.prototype.__proto__ || Object.getPrototypeOf(InputElement.prototype), 'attributeChangedCallback', this).call(this, name, last, current);
}
}
/**
* @attribute placeholder
* @type {String}
* @description
* [en]Placeholder text. In Material Design, this placeholder will be a floating label.[/en]
* [ja][/ja]
*/
/**
* @attribute float
* @description
* [en]If this attribute is present, the placeholder will be animated in Material Design.[/en]
* [ja]この属性が設定された時、ラベルはアニメーションするようになります。[/ja]
*/
/**
* @attribute type
* @type {String}
* @description
* [en]
* Specify the input type. This is the same as the "type" attribute for normal inputs. It expects strict text types such as `text`, `password`, etc. For checkbox, radio button, select or range, please have a look at the corresponding elements.
*
* Please take a look at [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type) for an exhaustive list of possible values. Depending on the platform and browser version some of these might not work.
* [/en]
* [ja][/ja]
*/
/**
* @attribute input-id
* @type {String}
* @description
* [en]Specify the "id" attribute of the inner `` element. This is useful when using `