);
}
}
const Button = (props, children) => (
);
const AppIcon = ({ img, emoji, theme, onChooseEmoji, isDropping,
onChooseFile, onDragOver, onDragLeave, onDrop }) => {
const bgColor = img ? 'transparent': theme;
let bgImage;
if (emoji) {
let emojiImage = emoji.image.replace('.png', '');
const imageSplit = emojiImage.split('-');
// For some reason we need to remove fe0f from images that just have it
// as blah-fe0f since those aren't named as such in the twemoji database
if (imageSplit.length == 2 && imageSplit[1] === 'fe0f') {
emojiImage = emojiImage.replace('-fe0f', '');
}
bgImage = `url('${emojiSvg(emojiImage)}')`;
} else {
bgImage = `url(${img})`;
}
return (
(document.querySelector('#file-app-icon') as HTMLInputElement).click()} title="Pick file">
{visibleEmojis.map(e => {
const em = emojis[e]
const x = em.sheet_x * (100 / 56);
const y = em.sheet_y * (100 / 56);
let name = null;
if (em.name) {
name = processName(em.name);
} else if (em.short_name) {
name = processName(em.short_name);
}
return (
Here’s a small text description for the card component.
Nothing more, nothing less.
Action`,
src: `
Card SubtitleCard Title
Here's a small text description for the card content. Nothing more, nothing less.
Action`
},
lists: {
display: `
Here’s a small text description for the card component.
Nothing more, nothing less.
Action`,
src: `
Card SubtitleCard Title
Here's a small text description for the card content. Nothing more, nothing less.
Action`,
},
lists: {
display: `
`,
* directives: [IONIC_DIRECTIVES]
* })
* class MyCustomCheckbox {}
*```
* Alternatively, you could:
*
* ```ts
* import {Checkbox, Icon} from 'ionic/ionic'
* ```
*
* along with any other components and add them individually:
*
* ```
* @Component({
* ...
* directives: [Checkbox, Icon]
* })
* ```
*
* However, using IONIC_DIRECTIVES will always *Just Work* with no
* performance overhead, so there is really no reason to not always use it.
*
* Pages have their content automatically wrapped in ``, so although
* you may see these tags if you inspect your markup, you don't need to include
* them in your templates.
*/
'use strict';
var Component, IONIC_DIRECTIVES;
_export('Page', Page);
function Page() {
var config = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
return function (cls) {
config.selector = 'ion-page';
config.directives = config.directives ? config.directives.concat(IONIC_DIRECTIVES) : IONIC_DIRECTIVES;
config.host = config.host || {};
config.host['[hidden]'] = '_hidden';
config.host['[class.tab-subpage]'] = '_tabSubPage';
var annotations = Reflect.getMetadata('annotations', cls) || [];
annotations.push(new Component(config));
Reflect.defineMetadata('annotations', annotations, cls);
return cls;
};
}
return {
setters: [function (_angular2Core) {
Component = _angular2Core.Component;
}, function (_configDirectives) {
IONIC_DIRECTIVES = _configDirectives.IONIC_DIRECTIVES;
}],
execute: function () {}
};
});
System.register('ionic/platform/platform', ['../util/util', '../util/dom'], function (_export) {
/**
* @name Platform
* @description
* Platform returns the availble information about your current platform.
* Platforms in Ionic 2 are much more complex then in V1, returns not just a single platform,
* but a hierarchy of information, such as a devices OS, phone vs tablet, or mobile vs browser.
* With this information you can completely custimize your app to fit any device and platform.
*
* @usage
* ```ts
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: Platform){
* this.platform = platform;
* }
* }
* ```
* @demo /docs/v3/demos/platform/
*/
'use strict';
var getQuerystring, extend, ready, windowDimensions, flushDimensionCache, Platform, PlatformNode, platformRegistry, platformDefault;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function insertSuperset(platformNode) {
var supersetPlaformName = platformNode.superset();
if (supersetPlaformName) {
// add a platform in between two exist platforms
// so we can build the correct hierarchy of active platforms
var supersetPlatform = new PlatformNode(supersetPlaformName);
supersetPlatform.parent(platformNode.parent());
supersetPlatform.child(platformNode);
if (supersetPlatform.parent()) {
supersetPlatform.parent().child(supersetPlatform);
}
platformNode.parent(supersetPlatform);
}
}
return {
setters: [function (_utilUtil) {
getQuerystring = _utilUtil.getQuerystring;
extend = _utilUtil.extend;
}, function (_utilDom) {
ready = _utilDom.ready;
windowDimensions = _utilDom.windowDimensions;
flushDimensionCache = _utilDom.flushDimensionCache;
}],
execute: function () {
Platform = (function () {
function Platform() {
var _this = this;
var platforms = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
_classCallCheck(this, Platform);
this._platforms = platforms;
this._versions = {};
this._dir = null;
this._lang = null;
this._onResizes = [];
this._readyPromise = new Promise(function (res) {
_this._readyResolve = res;
});
}
// Methods
// **********************************************
/**
* @param {string} platformName
* @returns {bool} returns true/false based on platform you place
* @description
* Depending on the platform name, isPlatform will return true or flase
*
* ```
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: Platform){
* this.platform = platform;
* if(this.platform.is('ios'){
* // what ever you need to do for
* // if the platfomr is ios
* }
* }
* }
* ```
*/
_createClass(Platform, [{
key: 'is',
value: function is(platformName) {
return this._platforms.indexOf(platformName) > -1;
}
/**
* @returns {array} the array of platforms
* @description
* Depending on what device you are on, `platforms` can return multiple values.
* Each possible value is a hierarchy of platforms. For example, on an iPhone,
* it would return mobile, ios, and iphone.
*
* ```
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: Platform){
* this.platform = platform;
* console.log(this.platform.platforms());
* // This will return an array of all the availble platforms
* // From if your on mobile, to mobile os, and device name
* }
* }
* ```
*/
}, {
key: 'platforms',
value: function platforms() {
// get the array of active platforms, which also knows the hierarchy,
// with the last one the most important
return this._platforms;
}
/**
* Returns an object containing information about the paltform
*
* ```
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: Platform){
* this.platform = platform;
* console.log(this.platform.versions());
* }
* }
* ```
* @param {string} [platformName] optional platformName
* @returns {object} An object with various platform info
*
*/
}, {
key: 'versions',
value: function versions(platformName) {
if (arguments.length) {
// get a specific platform's version
return this._versions[platformName];
}
// get all the platforms that have a valid parsed version
return this._versions;
}
/**
* @private
*/
}, {
key: 'version',
value: function version() {
for (var platformName in this._versions) {
if (this._versions[platformName]) {
return this._versions[platformName];
}
}
return {};
}
/**
* Returns a promise when the platform is ready and native functionality can be called
*
* ```
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: Platform){
* this.platform = platform;
* this.platform.ready().then(() => {
* console.log('Platform ready');
* // The platform is now ready, execute any native code you want
* });
* }
* }
* ```
* @returns {promise} Returns a promsie when device ready has fired
*/
}, {
key: 'ready',
value: function ready() {
return this._readyPromise;
}
/**
* @private
*/
}, {
key: 'prepareReady',
value: function prepareReady(config) {
var self = this;
function resolve() {
self._readyResolve(config);
}
if (this._engineReady) {
// the engine provide a ready promise, use this instead
this._engineReady(resolve);
} else {
// there is no custom ready method from the engine
// use the default dom ready
ready(resolve);
}
}
/**
* Set the app's language direction, which will update the `dir` attribute
* on the app's root `` element. We recommend the app's `index.html`
* file already has the correct `dir` attribute value set, such as
* `` or ``. This method is useful if the
* direction needs to be dynamically changed per user/session.
* [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
* @param {string} dir Examples: `rtl`, `ltr`
*/
}, {
key: 'setDir',
value: function setDir(dir, updateDocument) {
this._dir = (dir || '').toLowerCase();
if (updateDocument !== false) {
document.documentElement.setAttribute('dir', dir);
}
}
/**
* Returns app's language direction.
* We recommend the app's `index.html` file already has the correct `dir`
* attribute value set, such as `` or ``.
* [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
* @returns {string}
*/
}, {
key: 'dir',
value: function dir() {
return this._dir;
}
/**
* Returns if this app is using right-to-left language direction or not.
* We recommend the app's `index.html` file already has the correct `dir`
* attribute value set, such as `` or ``.
* [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
* @returns {boolean}
*/
}, {
key: 'isRTL',
value: function isRTL() {
return this._dir === 'rtl';
}
/**
* Set the app's language and optionally the country code, which will update
* the `lang` attribute on the app's root `` element.
* We recommend the app's `index.html` file already has the correct `lang`
* attribute value set, such as ``. This method is useful if
* the language needs to be dynamically changed per user/session.
* [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)
* @param {string} language Examples: `en-US`, `en-GB`, `ar`, `de`, `zh`, `es-MX`
*/
}, {
key: 'setLang',
value: function setLang(language, updateDocument) {
this._lang = language;
if (updateDocument !== false) {
document.documentElement.setAttribute('lang', language);
}
}
/**
* Returns app's language and optional country code.
* We recommend the app's `index.html` file already has the correct `lang`
* attribute value set, such as ``.
* [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)
* @returns {string}
*/
}, {
key: 'lang',
value: function lang() {
return this._lang;
}
// Methods meant to be overridden by the engine
// **********************************************
// Provided NOOP methods so they do not error when
// called by engines (the browser) doesn't provide them
/**
* @private
*/
}, {
key: 'on',
value: function on() {}
/**
* @private
*/
}, {
key: 'onHardwareBackButton',
value: function onHardwareBackButton() {}
/**
* @private
*/
}, {
key: 'registerBackButtonAction',
value: function registerBackButtonAction() {}
/**
* @private
*/
}, {
key: 'exitApp',
value: function exitApp() {}
/**
* @private
*/
}, {
key: 'fullScreen',
value: function fullScreen() {}
/**
* @private
*/
}, {
key: 'showStatusBar',
value: function showStatusBar() {}
// Getter/Setter Methods
// **********************************************
/**
* @private
*/
}, {
key: 'url',
value: function url(val) {
if (arguments.length) {
this._url = val;
this._qs = getQuerystring(val);
}
return this._url;
}
/**
* @private
*/
}, {
key: 'query',
value: function query(key) {
return (this._qs || {})[key];
}
/**
* @private
*/
}, {
key: 'userAgent',
value: function userAgent(val) {
if (arguments.length) {
this._ua = val;
}
return this._ua || '';
}
/**
* @private
*/
}, {
key: 'navigatorPlatform',
value: function navigatorPlatform(val) {
if (arguments.length) {
this._bPlt = val;
}
return this._bPlt || '';
}
/**
* @private
*/
}, {
key: 'width',
value: function width() {
return windowDimensions().width;
}
/**
* @private
*/
}, {
key: 'height',
value: function height() {
return windowDimensions().height;
}
/**
* @private
*/
}, {
key: 'isPortrait',
value: function isPortrait() {
return this.width() < this.height();
}
/**
* @private
*/
}, {
key: 'isLandscape',
value: function isLandscape() {
return !this.isPortrait();
}
/**
* @private
*/
}, {
key: 'windowResize',
value: function windowResize() {
var self = this;
clearTimeout(self._resizeTimer);
self._resizeTimer = setTimeout(function () {
flushDimensionCache();
for (var i = 0; i < self._onResizes.length; i++) {
try {
self._onResizes[i]();
} catch (e) {
console.error(e);
}
}
}, 250);
}
/**
* @private
*/
}, {
key: 'onResize',
value: function onResize(cb) {
this._onResizes.push(cb);
}
// Platform Registry
// **********************************************
/**
* @private
*/
}, {
key: 'testQuery',
/**
* @private
*/
value: function testQuery(queryValue, queryTestValue) {
var valueSplit = queryValue.toLowerCase().split(';');
return valueSplit.indexOf(queryTestValue) > -1;
}
/**
* @private
*/
}, {
key: 'testUserAgent',
value: function testUserAgent(userAgentExpression) {
var rgx = new RegExp(userAgentExpression, 'i');
return rgx.test(this._ua || '');
}
/**
* @private
*/
}, {
key: 'testNavigatorPlatform',
value: function testNavigatorPlatform(navigatorPlatformExpression) {
var rgx = new RegExp(navigatorPlatformExpression, 'i');
return rgx.test(this._bPlt);
}
/**
* @private
*/
}, {
key: 'matchUserAgentVersion',
value: function matchUserAgentVersion(userAgentExpression) {
if (this._ua && userAgentExpression) {
var val = this._ua.match(userAgentExpression);
if (val) {
return {
major: val[1],
minor: val[2]
};
}
}
}
/**
* @private
*/
}, {
key: 'isPlatform',
value: function isPlatform(queryTestValue, userAgentExpression) {
if (!userAgentExpression) {
userAgentExpression = queryTestValue;
}
var queryValue = this.query('ionicplatform');
if (queryValue) {
return this.testQuery(queryValue, queryTestValue);
}
return this.testUserAgent(userAgentExpression);
}
/**
* @private
*/
}, {
key: 'load',
value: function load(platformOverride) {
var rootPlatformNode = null;
var engineNode = null;
var self = this;
this.platformOverride = platformOverride;
// figure out the most specific platform and active engine
var tmpPlatform = null;
for (var platformName in platformRegistry) {
tmpPlatform = this.matchPlatform(platformName);
if (tmpPlatform) {
// we found a platform match!
// check if its more specific than the one we already have
if (tmpPlatform.isEngine) {
// because it matched then this should be the active engine
// you cannot have more than one active engine
engineNode = tmpPlatform;
} else if (!rootPlatformNode || tmpPlatform.depth > rootPlatformNode.depth) {
// only find the root node for platforms that are not engines
// set this node as the root since we either don't already
// have one, or this one is more specific that the current one
rootPlatformNode = tmpPlatform;
}
}
}
if (!rootPlatformNode) {
rootPlatformNode = new PlatformNode(platformDefault);
}
// build a Platform instance filled with the
// hierarchy of active platforms and settings
if (rootPlatformNode) {
// check if we found an engine node (cordova/node-webkit/etc)
if (engineNode) {
// add the engine to the first in the platform hierarchy
// the original rootPlatformNode now becomes a child
// of the engineNode, which is not the new root
engineNode.child(rootPlatformNode);
rootPlatformNode.parent(engineNode);
rootPlatformNode = engineNode;
// add any events which the engine would provide
// for example, Cordova provides its own ready event
var engineMethods = engineNode.methods();
engineMethods._engineReady = engineMethods.ready;
delete engineMethods.ready;
extend(this, engineMethods);
}
var platformNode = rootPlatformNode;
while (platformNode) {
insertSuperset(platformNode);
platformNode = platformNode.child();
}
// make sure the root noot is actually the root
// incase a node was inserted before the root
platformNode = rootPlatformNode.parent();
while (platformNode) {
rootPlatformNode = platformNode;
platformNode = platformNode.parent();
}
platformNode = rootPlatformNode;
while (platformNode) {
// set the array of active platforms with
// the last one in the array the most important
this._platforms.push(platformNode.name());
// get the platforms version if a version parser was provided
this._versions[platformNode.name()] = platformNode.version(this);
// go to the next platform child
platformNode = platformNode.child();
}
}
if (this._platforms.indexOf('mobile') > -1 && this._platforms.indexOf('cordova') === -1) {
this._platforms.push('mobileweb');
}
}
/**
* @private
*/
}, {
key: 'matchPlatform',
value: function matchPlatform(platformName) {
// build a PlatformNode and assign config data to it
// use it's getRoot method to build up its hierarchy
// depending on which platforms match
var platformNode = new PlatformNode(platformName);
var rootNode = platformNode.getRoot(this, 0);
if (rootNode) {
rootNode.depth = 0;
var childPlatform = rootNode.child();
while (childPlatform) {
rootNode.depth++;
childPlatform = childPlatform.child();
}
}
return rootNode;
}
}], [{
key: 'register',
value: function register(platformConfig) {
platformRegistry[platformConfig.name] = platformConfig;
}
/**
* @private
*/
}, {
key: 'registry',
value: function registry() {
return platformRegistry;
}
/**
* @private
*/
}, {
key: 'get',
value: function get(platformName) {
return platformRegistry[platformName] || {};
}
/**
* @private
*/
}, {
key: 'setDefault',
value: function setDefault(platformName) {
platformDefault = platformName;
}
}]);
return Platform;
})();
_export('Platform', Platform);
PlatformNode = (function () {
function PlatformNode(platformName) {
_classCallCheck(this, PlatformNode);
this.c = Platform.get(platformName);
this.isEngine = this.c.isEngine;
}
_createClass(PlatformNode, [{
key: 'name',
value: function name() {
return this.c.name;
}
}, {
key: 'settings',
value: function settings() {
return this.c.settings || {};
}
}, {
key: 'superset',
value: function superset() {
return this.c.superset;
}
}, {
key: 'methods',
value: function methods() {
return this.c.methods || {};
}
}, {
key: 'parent',
value: function parent(val) {
if (arguments.length) {
this._parent = val;
}
return this._parent;
}
}, {
key: 'child',
value: function child(val) {
if (arguments.length) {
this._child = val;
}
return this._child;
}
}, {
key: 'isMatch',
value: function isMatch(p) {
if (p.platformOverride && !this.isEngine) {
return p.platformOverride === this.c.name;
} else if (!this.c.isMatch) {
return false;
}
return this.c.isMatch(p);
}
}, {
key: 'version',
value: function version(p) {
if (this.c.versionParser) {
var v = this.c.versionParser(p);
if (v) {
var str = v.major + '.' + v.minor;
return {
str: str,
num: parseFloat(str),
major: parseInt(v.major, 10),
minor: parseInt(v.minor, 10)
};
}
}
}
}, {
key: 'getRoot',
value: function getRoot(p) {
if (this.isMatch(p)) {
var parents = this.getSubsetParents(this.name());
if (!parents.length) {
return this;
}
var platform = null;
var rootPlatform = null;
for (var i = 0; i < parents.length; i++) {
platform = new PlatformNode(parents[i]);
platform.child(this);
rootPlatform = platform.getRoot(p);
if (rootPlatform) {
this.parent(platform);
return rootPlatform;
}
}
}
return null;
}
}, {
key: 'getSubsetParents',
value: function getSubsetParents(subsetPlatformName) {
var platformRegistry = Platform.registry();
var parentPlatformNames = [];
var platform = null;
for (var platformName in platformRegistry) {
platform = platformRegistry[platformName];
if (platform.subsets && platform.subsets.indexOf(subsetPlatformName) > -1) {
parentPlatformNames.push(platformName);
}
}
return parentPlatformNames;
}
}]);
return PlatformNode;
})();
platformRegistry = {};
platformDefault = null;
}
};
});
System.register('ionic/platform/registry', ['./platform', '../util/dom'], function (_export) {
'use strict';
var Platform, windowLoad;
function isIOSDevice(p) {
// shortcut function to be reused internally
// checks navigator.platform to see if it's an actual iOS device
// this does not use the user-agent string because it is often spoofed
// an actual iPad will return true, a chrome dev tools iPad will return false
return p.testNavigatorPlatform('iphone|ipad|ipod');
}
return {
setters: [function (_platform) {
Platform = _platform.Platform;
}, function (_utilDom) {
windowLoad = _utilDom.windowLoad;
}],
execute: function () {
Platform.register({
name: 'core',
settings: {
mode: 'ios',
keyboardHeight: 290
}
});
Platform.setDefault('core');
Platform.register({
name: 'mobile'
});
Platform.register({
name: 'phablet',
isMatch: function isMatch(p) {
var smallest = Math.min(p.width(), p.height());
var largest = Math.max(p.width(), p.height());
return smallest > 390 && smallest < 520 && largest > 620 && largest < 800;
}
});
Platform.register({
name: 'tablet',
isMatch: function isMatch(p) {
var smallest = Math.min(p.width(), p.height());
var largest = Math.max(p.width(), p.height());
return smallest > 460 && smallest < 820 && largest > 780 && largest < 1400;
}
});
Platform.register({
name: 'android',
superset: 'mobile',
subsets: ['phablet', 'tablet'],
settings: {
activator: function activator(p) {
// md mode defaults to use ripple activator
// however, under-powered devices shouldn't use ripple
// if this a linux device, and is using Android Chrome v36 (Android 5.0)
// or above then use ripple, otherwise do not use a ripple effect
if (p.testNavigatorPlatform('linux')) {
var chromeVersion = p.matchUserAgentVersion(/Chrome\/(\d+).(\d+)?/);
if (chromeVersion) {
// linux android device using modern android chrome browser gets ripple
return parseInt(chromeVersion.major, 10) < 36 ? 'none' : 'ripple';
}
// linux android device not using chrome browser checks just android's version
if (p.version().major < 5) {
return 'none';
}
}
// fallback to always use ripple
return 'ripple';
},
hoverCSS: false,
keyboardHeight: 300,
mode: 'md',
scrollAssist: true
},
isMatch: function isMatch(p) {
return p.isPlatform('android', 'android|silk');
},
versionParser: function versionParser(p) {
return p.matchUserAgentVersion(/Android (\d+).(\d+)?/);
}
});
Platform.register({
name: 'ios',
superset: 'mobile',
subsets: ['ipad', 'iphone'],
settings: {
clickBlock: true,
hoverCSS: false,
keyboardHeight: 300,
mode: 'ios',
scrollAssist: isIOSDevice,
swipeBackEnabled: isIOSDevice,
swipeBackThreshold: 40,
tapPolyfill: isIOSDevice
},
isMatch: function isMatch(p) {
return p.isPlatform('ios', 'iphone|ipad|ipod');
},
versionParser: function versionParser(p) {
return p.matchUserAgentVersion(/OS (\d+)_(\d+)?/);
}
});
Platform.register({
name: 'ipad',
superset: 'tablet',
settings: {
keyboardHeight: 500
},
isMatch: function isMatch(p) {
return p.isPlatform('ipad');
}
});
Platform.register({
name: 'iphone',
subsets: ['phablet'],
isMatch: function isMatch(p) {
return p.isPlatform('iphone');
}
});
Platform.register({
name: 'windowsphone',
superset: 'mobile',
subsets: ['phablet', 'tablet'],
settings: {
mode: 'md'
},
isMatch: function isMatch(p) {
return p.isPlatform('windowsphone', 'windows phone');
},
versionParser: function versionParser(p) {
return p.matchUserAgentVersion(/Windows Phone (\d+).(\d+)?/);
}
});
Platform.register({
name: 'cordova',
isEngine: true,
methods: {
ready: function ready(resolve) {
function isReady() {
document.removeEventListener('deviceready', isReady);
resolve();
}
windowLoad(function () {
document.addEventListener('deviceready', isReady);
});
}
},
isMatch: function isMatch() {
return !!(window.cordova || window.PhoneGap || window.phonegap);
}
});
}
};
});
System.register('ionic/platform/storage', ['./storage/storage', './storage/local-storage', './storage/sql'], function (_export) {
'use strict';
return {
setters: [function (_storageStorage) {
for (var _key in _storageStorage) {
if (_key !== 'default') _export(_key, _storageStorage[_key]);
}
}, function (_storageLocalStorage) {
for (var _key2 in _storageLocalStorage) {
if (_key2 !== 'default') _export(_key2, _storageLocalStorage[_key2]);
}
}, function (_storageSql) {
for (var _key3 in _storageSql) {
if (_key3 !== 'default') _export(_key3, _storageSql[_key3]);
}
}],
execute: function () {}
};
});
System.register("ionic/translation/translate", ["angular2/core"], function (_export) {
/**
* @private
* Provide multi-language and i18n support in your app. Translate works by
* mapping full strings to language translated ones. That means that you don't need
* to provide strings for your default language, just new languages.
*
* @usage
* ```js
* Translate.translations({
* 'de': {
* 'Welcome to MyApp': 'Willkommen auf'
* }
* })
*
* Changing the default language:
*
* Translate.setLanguage('de');
* ```
*
* Usage in a template:
*
* ```js
* {{ 'Welcome to MyApp' | translate }}
* ```
*/
"use strict";
var Injectable, __decorate, __metadata, Translate;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Injectable = _angular2Core.Injectable;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Translate = (function () {
function Translate() {
_classCallCheck(this, Translate);
this._transMap = {};
}
_createClass(Translate, [{
key: "translations",
value: function translations(lang, map) {
this._transMap[lang] = map;
}
}, {
key: "setLanguage",
value: function setLanguage(lang) {
this._language = lang;
}
}, {
key: "getTranslations",
value: function getTranslations(lang) {
return this._transMap[lang];
}
}, {
key: "translate",
value: function translate(key, lang) {
// If the language isn't specified and we have no overridden one, return the string passed.
if (!lang && !this._language) {
return key;
}
var setLanguage = lang || this._language;
var map = this.getTranslations(setLanguage);
if (!map) {
console.warn('I18N: No translation for key', key, 'using language', setLanguage);
return '';
}
return this._getTranslation(map, key);
}
}, {
key: "_getTranslation",
value: function _getTranslation(map, key) {
return map && map[key] || '';
}
}]);
return Translate;
})();
_export("Translate", Translate);
_export("Translate", Translate = __decorate([Injectable(), __metadata('design:paramtypes', [])], Translate));
}
};
});
System.register("ionic/translation/translate_pipe", ["angular2/core", "./translate"], function (_export) {
/**
* @private
* The Translate pipe makes it easy to translate strings.
*
* @usage
* Translate using the current language or language set through Translate.setLanguage
* {{ 'Please enter your location' | translate }}
*
* Translate using a specific language
* {{ 'Please enter your location' | translate:"de" }}
*/
"use strict";
var Injectable, Pipe, Translate, __decorate, __metadata, TranslatePipe, _a;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Injectable = _angular2Core.Injectable;
Pipe = _angular2Core.Pipe;
}, function (_translate) {
Translate = _translate.Translate;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
TranslatePipe = (function () {
function TranslatePipe(translate) {
_classCallCheck(this, TranslatePipe);
this.translate = translate;
}
_createClass(TranslatePipe, [{
key: "transform",
value: function transform(value, args) {
var lang = undefined;
if (args.length > 0) {
lang = args[0];
}
return this.translate.translate(value, lang);
}
}, {
key: "supports",
value: function supports(obj) {
return true;
}
}]);
return TranslatePipe;
})();
_export("TranslatePipe", TranslatePipe);
_export("TranslatePipe", TranslatePipe = __decorate([Pipe({ name: 'translate' }), Injectable(), __metadata('design:paramtypes', [typeof (_a = typeof Translate !== 'undefined' && Translate) === 'function' && _a || Object])], TranslatePipe));
}
};
});
System.register('ionic/gestures/drag-gesture', ['./gesture', '../util'], function (_export) {
'use strict';
var Gesture, util, DragGesture;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
return {
setters: [function (_gesture) {
Gesture = _gesture.Gesture;
}, function (_util) {
util = _util;
}],
execute: function () {
DragGesture = (function (_Gesture) {
_inherits(DragGesture, _Gesture);
function DragGesture(element) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, DragGesture);
util.defaults(opts, {});
_get(Object.getPrototypeOf(DragGesture.prototype), 'constructor', this).call(this, element, opts);
}
_createClass(DragGesture, [{
key: 'listen',
value: function listen() {
var _this = this;
_get(Object.getPrototypeOf(DragGesture.prototype), 'listen', this).call(this);
this.on('panstart', function (ev) {
if (_this.onDragStart(ev) !== false) {
_this.dragging = true;
}
});
this.on('panmove', function (ev) {
if (!_this.dragging) return;
if (_this.onDrag(ev) === false) {
_this.dragging = false;
}
});
this.on('panend', function (ev) {
if (!_this.dragging) return;
_this.onDragEnd(ev);
_this.dragging = false;
});
this.hammertime.get('pan').set(this._options);
}
}, {
key: 'onDrag',
value: function onDrag() {}
}, {
key: 'onDragStart',
value: function onDragStart() {}
}, {
key: 'onDragEnd',
value: function onDragEnd() {}
}]);
return DragGesture;
})(Gesture);
_export('DragGesture', DragGesture);
}
};
});
System.register('ionic/gestures/gesture', ['../util', './hammer'], function (_export) {
/**
* A gesture recognizer class.
*
* TODO(mlynch): Re-enable the DOM event simulation that was causing issues (or verify hammer does this already, it might);
*/
'use strict';
var util, Hammer, Gesture;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
return {
setters: [function (_util) {
util = _util;
}, function (_hammer) {
Hammer = _hammer.Hammer;
}],
execute: function () {
Gesture = (function () {
function Gesture(element) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, Gesture);
util.defaults(opts, {
domEvents: true
});
this.element = element;
// Map 'x' or 'y' string to hammerjs opts
this.direction = opts.direction || 'x';
opts.direction = this.direction === 'x' ? Hammer.DIRECTION_HORIZONTAL : Hammer.DIRECTION_VERTICAL;
this._options = opts;
this._callbacks = {};
}
_createClass(Gesture, [{
key: 'options',
value: function options() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
util.extend(this._options, opts);
}
}, {
key: 'on',
value: function on(type, cb) {
if (type == 'pinch' || type == 'rotate') {
this.hammertime.get('pinch').set({ enable: true });
}
this.hammertime.on(type, cb);
(this._callbacks[type] || (this._callbacks[type] = [])).push(cb);
}
}, {
key: 'off',
value: function off(type, cb) {
this.hammertime.off(type, this._callbacks[type] ? cb : null);
}
}, {
key: 'listen',
value: function listen() {
this.hammertime = Hammer(this.element, this._options);
}
}, {
key: 'unlisten',
value: function unlisten() {
if (this.hammertime) {
for (var type in this._callbacks) {
for (var i = 0; i < this._callbacks[type].length; i++) {
this.hammertime.off(type, this._callbacks[type]);
}
}
this.hammertime.destroy();
this.hammertime = null;
this._callbacks = {};
}
}
}, {
key: 'destroy',
value: function destroy() {
this.unlisten();
}
}]);
return Gesture;
})();
_export('Gesture', Gesture);
}
};
});
System.register('ionic/gestures/hammer', [], function (_export) {
/*! Hammer.JS - v2.0.4 - 2014-09-28
* http://hammerjs.github.io/
*
* Copyright (c) 2014 Jorik Tangelder;
* Licensed under the MIT license */
'use strict';
var VENDOR_PREFIXES, TEST_ELEMENT, TYPE_FUNCTION, round, abs, now, _uniqueId, MOBILE_REGEX, SUPPORT_TOUCH, SUPPORT_POINTER_EVENTS, SUPPORT_ONLY_TOUCH, INPUT_TYPE_TOUCH, INPUT_TYPE_PEN, INPUT_TYPE_MOUSE, INPUT_TYPE_KINECT, COMPUTE_INTERVAL, INPUT_START, INPUT_MOVE, INPUT_END, INPUT_CANCEL, DIRECTION_NONE, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP, DIRECTION_DOWN, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, DIRECTION_ALL, PROPS_XY, PROPS_CLIENT_XY, MOUSE_INPUT_MAP, MOUSE_ELEMENT_EVENTS, MOUSE_WINDOW_EVENTS, POINTER_INPUT_MAP, IE10_POINTER_TYPE_ENUM, POINTER_ELEMENT_EVENTS, POINTER_WINDOW_EVENTS, SINGLE_TOUCH_INPUT_MAP, SINGLE_TOUCH_TARGET_EVENTS, SINGLE_TOUCH_WINDOW_EVENTS, TOUCH_INPUT_MAP, TOUCH_TARGET_EVENTS, PREFIXED_TOUCH_ACTION, NATIVE_TOUCH_ACTION, TOUCH_ACTION_COMPUTE, TOUCH_ACTION_AUTO, TOUCH_ACTION_MANIPULATION, TOUCH_ACTION_NONE, TOUCH_ACTION_PAN_X, TOUCH_ACTION_PAN_Y, STATE_POSSIBLE, STATE_BEGAN, STATE_CHANGED, STATE_ENDED, STATE_RECOGNIZED, STATE_CANCELLED, STATE_FAILED, STOP, FORCED_STOP;
/**
* set a timeout with a given scope
* @param {Function} fn
* @param {Number} timeout
* @param {Object} context
* @returns {number}
*/
function setTimeoutContext(fn, timeout, context) {
return setTimeout(bindFn(fn, context), timeout);
}
/**
* if the argument is an array, we want to execute the fn on each entry
* if it aint an array we don't want to do a thing.
* this is used by all the methods that accept a single and array argument.
* @param {*|Array} arg
* @param {String} fn
* @param {Object} [context]
* @returns {Boolean}
*/
function invokeArrayArg(arg, fn, context) {
if (Array.isArray(arg)) {
each(arg, context[fn], context);
return true;
}
return false;
}
/**
* walk objects and arrays
* @param {Object} obj
* @param {Function} iterator
* @param {Object} context
*/
function each(obj, iterator, context) {
var i;
if (!obj) {
return;
}
if (obj.forEach) {
obj.forEach(iterator, context);
} else if (obj.length !== undefined) {
i = 0;
while (i < obj.length) {
iterator.call(context, obj[i], i, obj);
i++;
}
} else {
for (i in obj) {
obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
}
}
}
/**
* extend object.
* means that properties in dest will be overwritten by the ones in src.
* @param {Object} dest
* @param {Object} src
* @param {Boolean} [merge]
* @returns {Object} dest
*/
function extend(dest, src, merge) {
var keys = Object.keys(src);
var i = 0;
while (i < keys.length) {
if (!merge || merge && dest[keys[i]] === undefined) {
dest[keys[i]] = src[keys[i]];
}
i++;
}
return dest;
}
/**
* merge the values from src in the dest.
* means that properties that exist in dest will not be overwritten by src
* @param {Object} dest
* @param {Object} src
* @returns {Object} dest
*/
function merge(dest, src) {
return extend(dest, src, true);
}
/**
* simple class inheritance
* @param {Function} child
* @param {Function} base
* @param {Object} [properties]
*/
function inherit(child, base, properties) {
var baseP = base.prototype,
childP;
childP = child.prototype = Object.create(baseP);
childP.constructor = child;
childP._super = baseP;
if (properties) {
extend(childP, properties);
}
}
/**
* simple function bind
* @param {Function} fn
* @param {Object} context
* @returns {Function}
*/
function bindFn(fn, context) {
return function boundFn() {
return fn.apply(context, arguments);
};
}
/**
* let a boolean value also be a function that must return a boolean
* this first item in args will be used as the context
* @param {Boolean|Function} val
* @param {Array} [args]
* @returns {Boolean}
*/
function boolOrFn(val, args) {
if (typeof val == TYPE_FUNCTION) {
return val.apply(args ? args[0] || undefined : undefined, args);
}
return val;
}
/**
* use the val2 when val1 is undefined
* @param {*} val1
* @param {*} val2
* @returns {*}
*/
function ifUndefined(val1, val2) {
return val1 === undefined ? val2 : val1;
}
/**
* addEventListener with multiple events at once
* @param {EventTarget} target
* @param {String} types
* @param {Function} handler
*/
function addEventListeners(target, types, handler) {
each(splitStr(types), function (type) {
//console.debug('hammer addEventListener', type, target.tagName);
target.addEventListener(type, handler, false);
});
}
/**
* removeEventListener with multiple events at once
* @param {EventTarget} target
* @param {String} types
* @param {Function} handler
*/
function removeEventListeners(target, types, handler) {
each(splitStr(types), function (type) {
//console.debug('hammer removeEventListener', type, target.tagName);
target.removeEventListener(type, handler, false);
});
}
/**
* find if a node is in the given parent
* @method hasParent
* @param {HTMLElement} node
* @param {HTMLElement} parent
* @return {Boolean} found
*/
function hasParent(node, parent) {
while (node) {
if (node == parent) {
return true;
}
node = node.parentNode;
}
return false;
}
/**
* small indexOf wrapper
* @param {String} str
* @param {String} find
* @returns {Boolean} found
*/
function inStr(str, find) {
return str.indexOf(find) > -1;
}
/**
* split string on whitespace
* @param {String} str
* @returns {Array} words
*/
function splitStr(str) {
return str.trim().split(/\s+/g);
}
/**
* find if a array contains the object using indexOf or a simple polyFill
* @param {Array} src
* @param {String} find
* @param {String} [findByKey]
* @return {Boolean|Number} false when not found, or the index
*/
function inArray(src, find, findByKey) {
if (src.indexOf && !findByKey) {
return src.indexOf(find);
} else {
var i = 0;
while (i < src.length) {
if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
return i;
}
i++;
}
return -1;
}
}
/**
* convert array-like objects to real arrays
* @param {Object} obj
* @returns {Array}
*/
function toArray(obj) {
return Array.prototype.slice.call(obj, 0);
}
/**
* unique array with objects based on a key (like 'id') or just by the array's value
* @param {Array} src [{id:1},{id:2},{id:1}]
* @param {String} [key]
* @param {Boolean} [sort=False]
* @returns {Array} [{id:1},{id:2}]
*/
function uniqueArray(src, key, sort) {
var results = [];
var values = [];
var i = 0;
while (i < src.length) {
var val = key ? src[i][key] : src[i];
if (inArray(values, val) < 0) {
results.push(src[i]);
}
values[i] = val;
i++;
}
if (sort) {
if (!key) {
results = results.sort();
} else {
results = results.sort(function sortUniqueArray(a, b) {
return a[key] > b[key];
});
}
}
return results;
}
/**
* get the prefixed property
* @param {Object} obj
* @param {String} property
* @returns {String|Undefined} prefixed
*/
function prefixed(obj, property) {
var prefix, prop;
var camelProp = property[0].toUpperCase() + property.slice(1);
var i = 0;
while (i < VENDOR_PREFIXES.length) {
prefix = VENDOR_PREFIXES[i];
prop = prefix ? prefix + camelProp : property;
if (prop in obj) {
return prop;
}
i++;
}
return undefined;
}
/**
* get a unique id
* @returns {number} uniqueId
*/
function uniqueId() {
return _uniqueId++;
}
/**
* get the window object of an element
* @param {HTMLElement} element
* @returns {DocumentView|Window}
*/
function getWindowForElement(element) {
var doc = element.ownerDocument;
return doc.defaultView || doc.parentWindow;
}
/**
* create new input type manager
* @param {Manager} manager
* @param {Function} callback
* @returns {Input}
* @constructor
*/
function Input(manager, callback) {
var self = this;
this.manager = manager;
this.callback = callback;
this.element = manager.element;
this.target = manager.options.inputTarget;
// smaller wrapper around the handler, for the scope and the enabled state of the manager,
// so when disabled the input events are completely bypassed.
this.domHandler = function (ev) {
if (boolOrFn(manager.options.enable, [manager])) {
self.handler(ev);
}
};
this.init();
}
/**
* create new input type manager
* called by the Manager constructor
* @param {Hammer} manager
* @returns {Input}
*/
function createInputInstance(manager) {
var Type;
var inputClass = manager.options.inputClass;
if (inputClass) {
Type = inputClass;
} else if (SUPPORT_POINTER_EVENTS) {
Type = PointerEventInput;
} else if (SUPPORT_ONLY_TOUCH) {
Type = TouchInput;
} else if (!SUPPORT_TOUCH) {
Type = MouseInput;
} else {
Type = TouchMouseInput;
}
return new Type(manager, inputHandler);
}
/**
* handle input events
* @param {Manager} manager
* @param {String} eventType
* @param {Object} input
*/
function inputHandler(manager, eventType, input) {
var pointersLen = input.pointers.length;
var changedPointersLen = input.changedPointers.length;
var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
input.isFirst = !!isFirst;
input.isFinal = !!isFinal;
if (isFirst) {
manager.session = {};
}
// source event is the normalized value of the domEvents
// like 'touchstart, mouseup, pointerdown'
input.eventType = eventType;
// compute scale, rotation etc
computeInputData(manager, input);
// emit secret event
manager.emit('hammer.input', input);
manager.recognize(input);
manager.session.prevInput = input;
}
/**
* extend the data with some usable properties like scale, rotate, velocity etc
* @param {Object} manager
* @param {Object} input
*/
function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// to compute scale and rotation we need to store the multiple touches
if (pointersLength > 1 && !session.firstMultiple) {
session.firstMultiple = simpleCloneInputData(input);
} else if (pointersLength === 1) {
session.firstMultiple = false;
}
var firstInput = session.firstInput;
var firstMultiple = session.firstMultiple;
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
var center = input.center = getCenter(pointers);
input.timeStamp = now();
input.deltaTime = input.timeStamp - firstInput.timeStamp;
input.angle = getAngle(offsetCenter, center);
input.distance = getDistance(offsetCenter, center);
computeDeltaXY(session, input);
input.offsetDirection = getDirection(input.deltaX, input.deltaY);
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
computeIntervalInputData(session, input);
// find the correct target
var target = manager.element;
if (hasParent(input.srcEvent.target, target)) {
target = input.srcEvent.target;
}
input.target = target;
}
function computeDeltaXY(session, input) {
var center = input.center;
var offset = session.offsetDelta || {};
var prevDelta = session.prevDelta || {};
var prevInput = session.prevInput || {};
if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
prevDelta = session.prevDelta = {
x: prevInput.deltaX || 0,
y: prevInput.deltaY || 0
};
offset = session.offsetDelta = {
x: center.x,
y: center.y
};
}
input.deltaX = prevDelta.x + (center.x - offset.x);
input.deltaY = prevDelta.y + (center.y - offset.y);
}
/**
* velocity is calculated every x ms
* @param {Object} session
* @param {Object} input
*/
function computeIntervalInputData(session, input) {
var last = session.lastInterval || input,
deltaTime = input.timeStamp - last.timeStamp,
velocity,
velocityX,
velocityY,
direction;
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
var deltaX = last.deltaX - input.deltaX;
var deltaY = last.deltaY - input.deltaY;
var v = getVelocity(deltaTime, deltaX, deltaY);
velocityX = v.x;
velocityY = v.y;
velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
direction = getDirection(deltaX, deltaY);
session.lastInterval = input;
} else {
// use latest velocity info if it doesn't overtake a minimum period
velocity = last.velocity;
velocityX = last.velocityX;
velocityY = last.velocityY;
direction = last.direction;
}
input.velocity = velocity;
input.velocityX = velocityX;
input.velocityY = velocityY;
input.direction = direction;
}
/**
* create a simple clone from the input used for storage of firstInput and firstMultiple
* @param {Object} input
* @returns {Object} clonedInputData
*/
function simpleCloneInputData(input) {
// make a simple copy of the pointers because we will get a reference if we don't
// we only need clientXY for the calculations
var pointers = [];
var i = 0;
while (i < input.pointers.length) {
pointers[i] = {
clientX: round(input.pointers[i].clientX),
clientY: round(input.pointers[i].clientY)
};
i++;
}
return {
timeStamp: now(),
pointers: pointers,
center: getCenter(pointers),
deltaX: input.deltaX,
deltaY: input.deltaY
};
}
/**
* get the center of all the pointers
* @param {Array} pointers
* @return {Object} center contains `x` and `y` properties
*/
function getCenter(pointers) {
var pointersLength = pointers.length;
// no need to loop when only one touch
if (pointersLength === 1) {
return {
x: round(pointers[0].clientX),
y: round(pointers[0].clientY)
};
}
var x = 0,
y = 0,
i = 0;
while (i < pointersLength) {
x += pointers[i].clientX;
y += pointers[i].clientY;
i++;
}
return {
x: round(x / pointersLength),
y: round(y / pointersLength)
};
}
/**
* calculate the velocity between two points. unit is in px per ms.
* @param {Number} deltaTime
* @param {Number} x
* @param {Number} y
* @return {Object} velocity `x` and `y`
*/
function getVelocity(deltaTime, x, y) {
return {
x: x / deltaTime || 0,
y: y / deltaTime || 0
};
}
/**
* get the direction between two points
* @param {Number} x
* @param {Number} y
* @return {Number} direction
*/
function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
}
/**
* calculate the absolute distance between two points
* @param {Object} p1 {x, y}
* @param {Object} p2 {x, y}
* @param {Array} [props] containing x and y keys
* @return {Number} distance
*/
function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]],
y = p2[props[1]] - p1[props[1]];
return Math.sqrt(x * x + y * y);
}
/**
* calculate the angle between two coordinates
* @param {Object} p1
* @param {Object} p2
* @param {Array} [props] containing x and y keys
* @return {Number} angle
*/
function getAngle(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]],
y = p2[props[1]] - p1[props[1]];
return Math.atan2(y, x) * 180 / Math.PI;
}
/**
* calculate the rotation degrees between two pointersets
* @param {Array} start array of pointers
* @param {Array} end array of pointers
* @return {Number} rotation
*/
function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
}
/**
* calculate the scale factor between two pointersets
* no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
* @param {Array} start array of pointers
* @param {Array} end array of pointers
* @return {Number} scale
*/
function getScale(start, end) {
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
}
/**
* Mouse events input
* @constructor
* @extends Input
*/
function MouseInput() {
this.evEl = MOUSE_ELEMENT_EVENTS;
this.evWin = MOUSE_WINDOW_EVENTS;
this.allow = true; // used by Input.TouchMouse to disable mouse events
this.pressed = false; // mousedown state
Input.apply(this, arguments);
}
/**
* Pointer events input
* @constructor
* @extends Input
*/
function PointerEventInput() {
this.evEl = POINTER_ELEMENT_EVENTS;
this.evWin = POINTER_WINDOW_EVENTS;
Input.apply(this, arguments);
this.store = this.manager.session.pointerEvents = [];
}
/**
* Touch events input
* @constructor
* @extends Input
*/
function SingleTouchInput() {
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
this.started = false;
Input.apply(this, arguments);
}
/**
* @this {TouchInput}
* @param {Object} ev
* @param {Number} type flag
* @returns {undefined|Array} [all, changed]
*/
function normalizeSingleTouches(ev, type) {
var all = toArray(ev.touches);
var changed = toArray(ev.changedTouches);
if (type & (INPUT_END | INPUT_CANCEL)) {
all = uniqueArray(all.concat(changed), 'identifier', true);
}
return [all, changed];
}
/**
* Multi-user touch events input
* @constructor
* @extends Input
*/
function TouchInput() {
this.evTarget = TOUCH_TARGET_EVENTS;
this.targetIds = {};
Input.apply(this, arguments);
}
/**
* @this {TouchInput}
* @param {Object} ev
* @param {Number} type flag
* @returns {undefined|Array} [all, changed]
*/
function getTouches(ev, type) {
var allTouches = toArray(ev.touches);
var targetIds = this.targetIds;
// when there is only one touch, the process can be simplified
if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
targetIds[allTouches[0].identifier] = true;
return [allTouches, allTouches];
}
var i,
targetTouches,
changedTouches = toArray(ev.changedTouches),
changedTargetTouches = [],
target = this.target;
// get target touches from touches
targetTouches = allTouches.filter(function (touch) {
return hasParent(touch.target, target);
});
// collect touches
if (type === INPUT_START) {
i = 0;
while (i < targetTouches.length) {
targetIds[targetTouches[i].identifier] = true;
i++;
}
}
// filter changed touches to only contain touches that exist in the collected target ids
i = 0;
while (i < changedTouches.length) {
if (targetIds[changedTouches[i].identifier]) {
changedTargetTouches.push(changedTouches[i]);
}
// cleanup removed touches
if (type & (INPUT_END | INPUT_CANCEL)) {
delete targetIds[changedTouches[i].identifier];
}
i++;
}
if (!changedTargetTouches.length) {
return;
}
return [
// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
}
/**
* Combined touch and mouse input
*
* Touch has a higher priority then mouse, and while touching no mouse events are allowed.
* This because touch devices also emit mouse events while doing a touch.
*
* @constructor
* @extends Input
*/
function TouchMouseInput() {
Input.apply(this, arguments);
var handler = bindFn(this.handler, this);
this.touch = new TouchInput(this.manager, handler);
this.mouse = new MouseInput(this.manager, handler);
}
/**
* Touch Action
* sets the touchAction property or uses the js alternative
* @param {Manager} manager
* @param {String} value
* @constructor
*/
function TouchAction(manager, value) {
this.manager = manager;
this.set(value);
}
/**
* when the touchActions are collected they are not a valid value, so we need to clean things up. *
* @param {String} actions
* @returns {*}
*/
function cleanTouchActions(actions) {
// none
if (inStr(actions, TOUCH_ACTION_NONE)) {
return TOUCH_ACTION_NONE;
}
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
// pan-x and pan-y can be combined
if (hasPanX && hasPanY) {
return TOUCH_ACTION_PAN_X + ' ' + TOUCH_ACTION_PAN_Y;
}
// pan-x OR pan-y
if (hasPanX || hasPanY) {
return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
}
// manipulation
if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
return TOUCH_ACTION_MANIPULATION;
}
return TOUCH_ACTION_AUTO;
}
/**
* Recognizer flow explained; *
* All recognizers have the initial state of POSSIBLE when a input session starts.
* The definition of a input session is from the first input until the last input, with all it's movement in it. *
* Example session for mouse-input: mousedown -> mousemove -> mouseup
*
* On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
* which determines with state it should be.
*
* If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
* POSSIBLE to give it another change on the next cycle.
*
* Possible
* |
* +-----+---------------+
* | |
* +-----+-----+ |
* | | |
* Failed Cancelled |
* +-------+------+
* | |
* Recognized Began
* |
* Changed
* |
* Ended/Recognized
*/
/**
* Recognizer
* Every recognizer needs to extend from this class.
* @constructor
* @param {Object} options
*/
function Recognizer(options) {
this.id = uniqueId();
this.manager = null;
this.options = merge(options || {}, this.defaults);
// default is enable true
this.options.enable = ifUndefined(this.options.enable, true);
this.state = STATE_POSSIBLE;
this.simultaneous = {};
this.requireFail = [];
}
/**
* get a usable string, used as event postfix
* @param {Const} state
* @returns {String} state
*/
function stateStr(state) {
if (state & STATE_CANCELLED) {
return 'cancel';
} else if (state & STATE_ENDED) {
return 'end';
} else if (state & STATE_CHANGED) {
return 'move';
} else if (state & STATE_BEGAN) {
return 'start';
}
return '';
}
/**
* direction cons to string
* @param {Const} direction
* @returns {String}
*/
function directionStr(direction) {
if (direction == DIRECTION_DOWN) {
return 'down';
} else if (direction == DIRECTION_UP) {
return 'up';
} else if (direction == DIRECTION_LEFT) {
return 'left';
} else if (direction == DIRECTION_RIGHT) {
return 'right';
}
return '';
}
/**
* get a recognizer by name if it is bound to a manager
* @param {Recognizer|String} otherRecognizer
* @param {Recognizer} recognizer
* @returns {Recognizer}
*/
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
var manager = recognizer.manager;
if (manager) {
return manager.get(otherRecognizer);
}
return otherRecognizer;
}
/**
* This recognizer is just used as a base for the simple attribute recognizers.
* @constructor
* @extends Recognizer
*/
function AttrRecognizer() {
Recognizer.apply(this, arguments);
}
/**
* Pan
* Recognized when the pointer is down and moved in the allowed direction.
* @constructor
* @extends AttrRecognizer
*/
function PanRecognizer() {
AttrRecognizer.apply(this, arguments);
this.pX = null;
this.pY = null;
}
/**
* Pinch
* Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
* @constructor
* @extends AttrRecognizer
*/
function PinchRecognizer() {
AttrRecognizer.apply(this, arguments);
}
/**
* Press
* Recognized when the pointer is down for x ms without any movement.
* @constructor
* @extends Recognizer
*/
function PressRecognizer() {
Recognizer.apply(this, arguments);
this._timer = null;
this._input = null;
}
/**
* Rotate
* Recognized when two or more pointer are moving in a circular motion.
* @constructor
* @extends AttrRecognizer
*/
function RotateRecognizer() {
AttrRecognizer.apply(this, arguments);
}
/**
* Swipe
* Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
* @constructor
* @extends AttrRecognizer
*/
function SwipeRecognizer() {
AttrRecognizer.apply(this, arguments);
}
/**
* A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
* between the given interval and position. The delay option can be used to recognize multi-taps without firing
* a single tap.
*
* The eventData from the emitted event contains the property `tapCount`, which contains the amount of
* multi-taps being recognized.
* @constructor
* @extends Recognizer
*/
function TapRecognizer() {
Recognizer.apply(this, arguments);
// previous time and center,
// used for tap counting
this.pTime = false;
this.pCenter = false;
this._timer = null;
this._input = null;
this.count = 0;
}
/**
* Simple way to create an manager with a default set of recognizers.
* @param {HTMLElement} element
* @param {Object} [options]
* @constructor
*/
function Hammer(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
return new Manager(element, options);
}
/**
* @const {string}
*/
/**
* Manager
* @param {HTMLElement} element
* @param {Object} [options]
* @constructor
*/
function Manager(element, options) {
options = options || {};
this.options = merge(options, Hammer.defaults);
this.options.inputTarget = this.options.inputTarget || element;
this.handlers = {};
this.session = {};
this.recognizers = [];
this.element = element;
this.input = createInputInstance(this);
this.touchAction = new TouchAction(this, this.options.touchAction);
toggleCssProps(this, true);
each(options.recognizers, function (item) {
var recognizer = this.add(new item[0](item[1]));
item[2] && recognizer.recognizeWith(item[2]);
item[3] && recognizer.requireFailure(item[3]);
}, this);
}
/**
* add/remove the css properties as defined in manager.options.cssProps
* @param {Manager} manager
* @param {Boolean} add
*/
function toggleCssProps(manager, add) {
var element = manager.element;
each(manager.options.cssProps, function (value, name) {
element.style[prefixed(element.style, name)] = add ? value : '';
});
}
/**
* trigger dom event
* @param {String} event
* @param {Object} data
*/
function triggerDomEvent(event, data) {
var gestureEvent = document.createEvent('Event');
gestureEvent.initEvent(event, true, true);
gestureEvent.gesture = data;
data.target.dispatchEvent(gestureEvent);
}
return {
setters: [],
execute: function () {
VENDOR_PREFIXES = ['', 'webkit', 'moz', 'MS', 'ms', 'o'];
TEST_ELEMENT = document.createElement('div');
TYPE_FUNCTION = 'function';
round = Math.round;
abs = Math.abs;
now = Date.now;
_uniqueId = 1;
MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
SUPPORT_TOUCH = 'ontouchstart' in window;
SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
INPUT_TYPE_TOUCH = 'touch';
INPUT_TYPE_PEN = 'pen';
INPUT_TYPE_MOUSE = 'mouse';
INPUT_TYPE_KINECT = 'kinect';
COMPUTE_INTERVAL = 25;
INPUT_START = 1;
INPUT_MOVE = 2;
INPUT_END = 4;
INPUT_CANCEL = 8;
DIRECTION_NONE = 1;
DIRECTION_LEFT = 2;
DIRECTION_RIGHT = 4;
DIRECTION_UP = 8;
DIRECTION_DOWN = 16;
DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
PROPS_XY = ['x', 'y'];
PROPS_CLIENT_XY = ['clientX', 'clientY'];
Input.prototype = {
/**
* should handle the inputEvent data and trigger the callback
* @virtual
*/
handler: function handler() {},
/**
* bind the events
*/
init: function init() {
//console.debug('hammer Input init')
this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
},
/**
* unbind the events
*/
destroy: function destroy() {
this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
}
};MOUSE_INPUT_MAP = {
mousedown: INPUT_START,
mousemove: INPUT_MOVE,
mouseup: INPUT_END
};
MOUSE_ELEMENT_EVENTS = 'mousedown';
MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
inherit(MouseInput, Input, {
/**
* handle mouse events
* @param {Object} ev
*/
handler: function MEhandler(ev) {
var eventType = MOUSE_INPUT_MAP[ev.type];
// on start we want to have the left mouse button down
if (eventType & INPUT_START && ev.button === 0) {
this.pressed = true;
}
if (eventType & INPUT_MOVE && ev.which !== 1) {
eventType = INPUT_END;
}
// mouse must be down, and mouse events are allowed (see the TouchMouse input)
if (!this.pressed || !this.allow) {
return;
}
if (eventType & INPUT_END) {
this.pressed = false;
}
this.callback(this.manager, eventType, {
pointers: [ev],
changedPointers: [ev],
pointerType: INPUT_TYPE_MOUSE,
srcEvent: ev
});
}
});
POINTER_INPUT_MAP = {
pointerdown: INPUT_START,
pointermove: INPUT_MOVE,
pointerup: INPUT_END,
pointercancel: INPUT_CANCEL,
pointerout: INPUT_CANCEL
};
// in IE10 the pointer types is defined as an enum
IE10_POINTER_TYPE_ENUM = {
2: INPUT_TYPE_TOUCH,
3: INPUT_TYPE_PEN,
4: INPUT_TYPE_MOUSE,
5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
};
POINTER_ELEMENT_EVENTS = 'pointerdown';
POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
// IE10 has prefixed support, and case-sensitive
if (window.MSPointerEvent) {
POINTER_ELEMENT_EVENTS = 'MSPointerDown';
POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
}inherit(PointerEventInput, Input, {
/**
* handle mouse events
* @param {Object} ev
*/
handler: function PEhandler(ev) {
var store = this.store;
var removePointer = false;
var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
var isTouch = pointerType == INPUT_TYPE_TOUCH;
// get index of the event in the store
var storeIndex = inArray(store, ev.pointerId, 'pointerId');
// start and mouse must be down
if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
if (storeIndex < 0) {
store.push(ev);
storeIndex = store.length - 1;
}
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
removePointer = true;
}
// it not found, so the pointer hasn't been down (so it's probably a hover)
if (storeIndex < 0) {
return;
}
// update the event in the store
store[storeIndex] = ev;
this.callback(this.manager, eventType, {
pointers: store,
changedPointers: [ev],
pointerType: pointerType,
srcEvent: ev
});
if (removePointer) {
// remove from the store
store.splice(storeIndex, 1);
}
}
});
SINGLE_TOUCH_INPUT_MAP = {
touchstart: INPUT_START,
touchmove: INPUT_MOVE,
touchend: INPUT_END,
touchcancel: INPUT_CANCEL
};
SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
inherit(SingleTouchInput, Input, {
handler: function TEhandler(ev) {
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
// should we handle the touch events?
if (type === INPUT_START) {
this.started = true;
}
if (!this.started) {
return;
}
var touches = normalizeSingleTouches.call(this, ev, type);
// when done, reset the started state
if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
this.started = false;
}
this.callback(this.manager, type, {
pointers: touches[0],
changedPointers: touches[1],
pointerType: INPUT_TYPE_TOUCH,
srcEvent: ev
});
}
});TOUCH_INPUT_MAP = {
touchstart: INPUT_START,
touchmove: INPUT_MOVE,
touchend: INPUT_END,
touchcancel: INPUT_CANCEL
};
TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
inherit(TouchInput, Input, {
handler: function MTEhandler(ev) {
var type = TOUCH_INPUT_MAP[ev.type];
var touches = getTouches.call(this, ev, type);
if (!touches) {
return;
}
this.callback(this.manager, type, {
pointers: touches[0],
changedPointers: touches[1],
pointerType: INPUT_TYPE_TOUCH,
srcEvent: ev
});
}
});inherit(TouchMouseInput, Input, {
/**
* handle mouse and touch events
* @param {Hammer} manager
* @param {String} inputEvent
* @param {Object} inputData
*/
handler: function TMEhandler(manager, inputEvent, inputData) {
var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH,
isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
// when we're in a touch event, so block all upcoming mouse events
// most mobile browser also emit mouseevents, right after touchstart
if (isTouch) {
this.mouse.allow = false;
} else if (isMouse && !this.mouse.allow) {
return;
}
// reset the allowMouse when we're done
if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
this.mouse.allow = true;
}
this.callback(manager, inputEvent, inputData);
},
/**
* remove the event listeners
*/
destroy: function destroy() {
this.touch.destroy();
this.mouse.destroy();
}
});
PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
// magical touchAction value
TOUCH_ACTION_COMPUTE = 'compute';
TOUCH_ACTION_AUTO = 'auto';
TOUCH_ACTION_MANIPULATION = 'manipulation';
// not implemented
TOUCH_ACTION_NONE = 'none';
TOUCH_ACTION_PAN_X = 'pan-x';
TOUCH_ACTION_PAN_Y = 'pan-y';
TouchAction.prototype = {
/**
* set the touchAction value on the element or enable the polyfill
* @param {String} value
*/
set: function set(value) {
// find out the touch-action by the event handlers
if (value == TOUCH_ACTION_COMPUTE) {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
},
/**
* just re-set the touchAction value
*/
update: function update() {
this.set(this.manager.options.touchAction);
},
/**
* compute the value for the touchAction property based on the recognizer's settings
* @returns {String} value
*/
compute: function compute() {
var actions = [];
each(this.manager.recognizers, function (recognizer) {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
});
return cleanTouchActions(actions.join(' '));
},
/**
* this method is called on each input cycle and provides the preventing of the browser behavior
* @param {Object} input
*/
preventDefaults: function preventDefaults(input) {
// not needed with native support for the touchAction property
if (NATIVE_TOUCH_ACTION) {
return;
}
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
srcEvent.preventDefault();
return;
}
var actions = this.actions;
var hasNone = inStr(actions, TOUCH_ACTION_NONE);
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
return this.preventSrc(srcEvent);
}
},
/**
* call preventDefault to prevent the browser's default behavior (scrolling in most cases)
* @param {Object} srcEvent
*/
preventSrc: function preventSrc(srcEvent) {
this.manager.session.prevented = true;
srcEvent.preventDefault();
}
};STATE_POSSIBLE = 1;
STATE_BEGAN = 2;
STATE_CHANGED = 4;
STATE_ENDED = 8;
STATE_RECOGNIZED = STATE_ENDED;
STATE_CANCELLED = 16;
STATE_FAILED = 32;
Recognizer.prototype = {
/**
* @virtual
* @type {Object}
*/
defaults: {},
/**
* set options
* @param {Object} options
* @return {Recognizer}
*/
set: function set(options) {
extend(this.options, options);
// also update the touchAction, in case something changed about the directions/enabled state
this.manager && this.manager.touchAction.update();
return this;
},
/**
* recognize simultaneous with an other recognizer.
* @param {Recognizer} otherRecognizer
* @returns {Recognizer} this
*/
recognizeWith: function recognizeWith(otherRecognizer) {
if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
return this;
}
var simultaneous = this.simultaneous;
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
if (!simultaneous[otherRecognizer.id]) {
simultaneous[otherRecognizer.id] = otherRecognizer;
otherRecognizer.recognizeWith(this);
}
return this;
},
/**
* drop the simultaneous link. it doesnt remove the link on the other recognizer.
* @param {Recognizer} otherRecognizer
* @returns {Recognizer} this
*/
dropRecognizeWith: function dropRecognizeWith(otherRecognizer) {
if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
return this;
}
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
delete this.simultaneous[otherRecognizer.id];
return this;
},
/**
* recognizer can only run when an other is failing
* @param {Recognizer} otherRecognizer
* @returns {Recognizer} this
*/
requireFailure: function requireFailure(otherRecognizer) {
if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
return this;
}
var requireFail = this.requireFail;
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
if (inArray(requireFail, otherRecognizer) === -1) {
requireFail.push(otherRecognizer);
otherRecognizer.requireFailure(this);
}
return this;
},
/**
* drop the requireFailure link. it does not remove the link on the other recognizer.
* @param {Recognizer} otherRecognizer
* @returns {Recognizer} this
*/
dropRequireFailure: function dropRequireFailure(otherRecognizer) {
if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
return this;
}
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
var index = inArray(this.requireFail, otherRecognizer);
if (index > -1) {
this.requireFail.splice(index, 1);
}
return this;
},
/**
* has require failures boolean
* @returns {boolean}
*/
hasRequireFailures: function hasRequireFailures() {
return this.requireFail.length > 0;
},
/**
* if the recognizer can recognize simultaneous with an other recognizer
* @param {Recognizer} otherRecognizer
* @returns {Boolean}
*/
canRecognizeWith: function canRecognizeWith(otherRecognizer) {
return !!this.simultaneous[otherRecognizer.id];
},
/**
* You should use `tryEmit` instead of `emit` directly to check
* that all the needed recognizers has failed before emitting.
* @param {Object} input
*/
emit: function emit(input) {
var self = this;
var state = this.state;
function emit(withState) {
self.manager.emit(self.options.event + (withState ? stateStr(state) : ''), input);
}
// 'panstart' and 'panmove'
if (state < STATE_ENDED) {
emit(true);
}
emit(); // simple 'eventName' events
// panend and pancancel
if (state >= STATE_ENDED) {
emit(true);
}
},
/**
* Check that all the require failure recognizers has failed,
* if true, it emits a gesture event,
* otherwise, setup the state to FAILED.
* @param {Object} input
*/
tryEmit: function tryEmit(input) {
if (this.canEmit()) {
return this.emit(input);
}
// it's failing anyway
this.state = STATE_FAILED;
},
/**
* can we emit?
* @returns {boolean}
*/
canEmit: function canEmit() {
var i = 0;
while (i < this.requireFail.length) {
if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
return false;
}
i++;
}
return true;
},
/**
* update the recognizer
* @param {Object} inputData
*/
recognize: function recognize(inputData) {
// make a new copy of the inputData
// so we can change the inputData without messing up the other recognizers
var inputDataClone = extend({}, inputData);
// is is enabled and allow recognizing?
if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
this.reset();
this.state = STATE_FAILED;
return;
}
// reset when we've reached the end
if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
this.state = STATE_POSSIBLE;
}
this.state = this.process(inputDataClone);
// the recognizer has recognized a gesture
// so trigger an event
if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
this.tryEmit(inputDataClone);
}
},
/**
* return the state of the recognizer
* the actual recognizing happens in this method
* @virtual
* @param {Object} inputData
* @returns {Const} STATE
*/
process: function process(inputData) {},
/**
* return the preferred touch-action
* @virtual
* @returns {Array}
*/
getTouchAction: function getTouchAction() {},
/**
* called when the gesture isn't allowed to recognize
* like when another is being recognized or it is disabled
* @virtual
*/
reset: function reset() {}
};inherit(AttrRecognizer, Recognizer, {
/**
* @namespace
* @memberof AttrRecognizer
*/
defaults: {
/**
* @type {Number}
* @default 1
*/
pointers: 1
},
/**
* Used to check if it the recognizer receives valid input, like input.distance > 10.
* @memberof AttrRecognizer
* @param {Object} input
* @returns {Boolean} recognized
*/
attrTest: function attrTest(input) {
var optionPointers = this.options.pointers;
return optionPointers === 0 || input.pointers.length === optionPointers;
},
/**
* Process the input and return the state for the recognizer
* @memberof AttrRecognizer
* @param {Object} input
* @returns {*} State
*/
process: function process(input) {
var state = this.state;
var eventType = input.eventType;
var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
var isValid = this.attrTest(input);
// on cancel input and we've recognized before, return STATE_CANCELLED
if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
return state | STATE_CANCELLED;
} else if (isRecognized || isValid) {
if (eventType & INPUT_END) {
return state | STATE_ENDED;
} else if (!(state & STATE_BEGAN)) {
return STATE_BEGAN;
}
return state | STATE_CHANGED;
}
return STATE_FAILED;
}
});inherit(PanRecognizer, AttrRecognizer, {
/**
* @namespace
* @memberof PanRecognizer
*/
defaults: {
event: 'pan',
threshold: 10,
pointers: 1,
direction: DIRECTION_ALL
},
getTouchAction: function getTouchAction() {
var direction = this.options.direction;
var actions = [];
if (direction & DIRECTION_HORIZONTAL) {
actions.push(TOUCH_ACTION_PAN_Y);
}
if (direction & DIRECTION_VERTICAL) {
actions.push(TOUCH_ACTION_PAN_X);
}
return actions;
},
directionTest: function directionTest(input) {
var options = this.options;
var hasMoved = true;
var distance = input.distance;
var direction = input.direction;
var x = input.deltaX;
var y = input.deltaY;
// lock to axis?
if (!(direction & options.direction)) {
if (options.direction & DIRECTION_HORIZONTAL) {
direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
hasMoved = x != this.pX;
distance = Math.abs(input.deltaX);
} else {
direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
hasMoved = y != this.pY;
distance = Math.abs(input.deltaY);
}
}
input.direction = direction;
return hasMoved && distance > options.threshold && direction & options.direction;
},
attrTest: function attrTest(input) {
return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
},
emit: function emit(input) {
this.pX = input.deltaX;
this.pY = input.deltaY;
var direction = directionStr(input.direction);
if (direction) {
this.manager.emit(this.options.event + direction, input);
}
this._super.emit.call(this, input);
}
});inherit(PinchRecognizer, AttrRecognizer, {
/**
* @namespace
* @memberof PinchRecognizer
*/
defaults: {
event: 'pinch',
threshold: 0,
pointers: 2
},
getTouchAction: function getTouchAction() {
return [TOUCH_ACTION_NONE];
},
attrTest: function attrTest(input) {
return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
},
emit: function emit(input) {
this._super.emit.call(this, input);
if (input.scale !== 1) {
var inOut = input.scale < 1 ? 'in' : 'out';
this.manager.emit(this.options.event + inOut, input);
}
}
});inherit(PressRecognizer, Recognizer, {
/**
* @namespace
* @memberof PressRecognizer
*/
defaults: {
event: 'press',
pointers: 1,
time: 500,
threshold: 5 // a minimal movement is ok, but keep it low
},
getTouchAction: function getTouchAction() {
return [TOUCH_ACTION_AUTO];
},
process: function process(input) {
var options = this.options;
var validPointers = input.pointers.length === options.pointers;
var validMovement = input.distance < options.threshold;
var validTime = input.deltaTime > options.time;
this._input = input;
// we only allow little movement
// and we've reached an end event, so a tap is possible
if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
this.reset();
} else if (input.eventType & INPUT_START) {
this.reset();
this._timer = setTimeoutContext(function () {
this.state = STATE_RECOGNIZED;
this.tryEmit();
}, options.time, this);
} else if (input.eventType & INPUT_END) {
return STATE_RECOGNIZED;
}
return STATE_FAILED;
},
reset: function reset() {
clearTimeout(this._timer);
},
emit: function emit(input) {
if (this.state !== STATE_RECOGNIZED) {
return;
}
if (input && input.eventType & INPUT_END) {
this.manager.emit(this.options.event + 'up', input);
} else {
this._input.timeStamp = now();
this.manager.emit(this.options.event, this._input);
}
}
});inherit(RotateRecognizer, AttrRecognizer, {
/**
* @namespace
* @memberof RotateRecognizer
*/
defaults: {
event: 'rotate',
threshold: 0,
pointers: 2
},
getTouchAction: function getTouchAction() {
return [TOUCH_ACTION_NONE];
},
attrTest: function attrTest(input) {
return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
}
});inherit(SwipeRecognizer, AttrRecognizer, {
/**
* @namespace
* @memberof SwipeRecognizer
*/
defaults: {
event: 'swipe',
threshold: 10,
velocity: 0.65,
direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
pointers: 1
},
getTouchAction: function getTouchAction() {
return PanRecognizer.prototype.getTouchAction.call(this);
},
attrTest: function attrTest(input) {
var direction = this.options.direction;
var velocity;
if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
velocity = input.velocity;
} else if (direction & DIRECTION_HORIZONTAL) {
velocity = input.velocityX;
} else if (direction & DIRECTION_VERTICAL) {
velocity = input.velocityY;
}
return this._super.attrTest.call(this, input) && direction & input.direction && input.distance > this.options.threshold && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
},
emit: function emit(input) {
var direction = directionStr(input.direction);
if (direction) {
this.manager.emit(this.options.event + direction, input);
}
this.manager.emit(this.options.event, input);
}
});inherit(TapRecognizer, Recognizer, {
/**
* @namespace
* @memberof PinchRecognizer
*/
defaults: {
event: 'tap',
pointers: 1,
taps: 1,
interval: 300,
time: 250,
threshold: 2,
posThreshold: 10 // a multi-tap can be a bit off the initial position
},
getTouchAction: function getTouchAction() {
return [TOUCH_ACTION_MANIPULATION];
},
process: function process(input) {
var options = this.options;
var validPointers = input.pointers.length === options.pointers;
var validMovement = input.distance < options.threshold;
var validTouchTime = input.deltaTime < options.time;
this.reset();
if (input.eventType & INPUT_START && this.count === 0) {
return this.failTimeout();
}
// we only allow little movement
// and we've reached an end event, so a tap is possible
if (validMovement && validTouchTime && validPointers) {
if (input.eventType != INPUT_END) {
return this.failTimeout();
}
var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
this.pTime = input.timeStamp;
this.pCenter = input.center;
if (!validMultiTap || !validInterval) {
this.count = 1;
} else {
this.count += 1;
}
this._input = input;
// if tap count matches we have recognized it,
// else it has began recognizing...
var tapCount = this.count % options.taps;
if (tapCount === 0) {
// no failing requirements, immediately trigger the tap event
// or wait as long as the multitap interval to trigger
if (!this.hasRequireFailures()) {
return STATE_RECOGNIZED;
} else {
this._timer = setTimeoutContext(function () {
this.state = STATE_RECOGNIZED;
this.tryEmit();
}, options.interval, this);
return STATE_BEGAN;
}
}
}
return STATE_FAILED;
},
failTimeout: function failTimeout() {
this._timer = setTimeoutContext(function () {
this.state = STATE_FAILED;
}, this.options.interval, this);
return STATE_FAILED;
},
reset: function reset() {
clearTimeout(this._timer);
},
emit: function emit() {
if (this.state == STATE_RECOGNIZED) {
this._input.tapCount = this.count;
this.manager.emit(this.options.event, this._input);
}
}
});Hammer.VERSION = '2.0.4';
/**
* default settings
* @namespace
*/
Hammer.defaults = {
/**
* set if DOM events are being triggered.
* But this is slower and unused by simple implementations, so disabled by default.
* @type {Boolean}
* @default false
*/
domEvents: false,
/**
* The value for the touchAction property/fallback.
* When set to `compute` it will magically set the correct value based on the added recognizers.
* @type {String}
* @default compute
*/
touchAction: TOUCH_ACTION_COMPUTE,
/**
* @type {Boolean}
* @default true
*/
enable: true,
/**
* EXPERIMENTAL FEATURE -- can be removed/changed
* Change the parent input target element.
* If Null, then it is being set the to main element.
* @type {Null|EventTarget}
* @default null
*/
inputTarget: null,
/**
* force an input class
* @type {Null|Function}
* @default null
*/
inputClass: null,
/**
* Default recognizer setup when calling `Hammer()`
* When creating a new Manager these will be skipped.
* @type {Array}
*/
preset: [
// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
[RotateRecognizer, { enable: false }], [PinchRecognizer, { enable: false }, ['rotate']], [SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }], [PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ['swipe']], [TapRecognizer], [TapRecognizer, { event: 'doubletap', taps: 2 }, ['tap']], [PressRecognizer]],
/**
* Some CSS properties can be used to improve the working of Hammer.
* Add them to this method and they will be set when creating a new Manager.
* @namespace
*/
cssProps: {
/**
* Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
* @type {String}
* @default 'none'
*/
userSelect: 'none',
/**
* Disable the Windows Phone grippers when pressing an element.
* @type {String}
* @default 'none'
*/
touchSelect: 'none',
/**
* Disables the default callout shown when you touch and hold a touch target.
* On iOS, when you touch and hold a touch target such as a link, Safari displays
* a callout containing information about the link. This property allows you to disable that callout.
* @type {String}
* @default 'none'
*/
touchCallout: 'none',
/**
* Specifies whether zooming is enabled. Used by IE10>
* @type {String}
* @default 'none'
*/
contentZooming: 'none',
/**
* Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
* @type {String}
* @default 'none'
*/
userDrag: 'none',
/**
* Overrides the highlight color shown when the user taps a link or a JavaScript
* clickable element in iOS. This property obeys the alpha value, if specified.
* @type {String}
* @default 'rgba(0,0,0,0)'
*/
tapHighlightColor: 'rgba(0,0,0,0)'
}
};
STOP = 1;
FORCED_STOP = 2;
Manager.prototype = {
/**
* set options
* @param {Object} options
* @returns {Manager}
*/
set: function set(options) {
extend(this.options, options);
// Options that need a little more setup
if (options.touchAction) {
this.touchAction.update();
}
if (options.inputTarget) {
// Clean up existing event listeners and reinitialize
this.input.destroy();
this.input.target = options.inputTarget;
this.input.init();
}
return this;
},
/**
* stop recognizing for this session.
* This session will be discarded, when a new [input]start event is fired.
* When forced, the recognizer cycle is stopped immediately.
* @param {Boolean} [force]
*/
stop: function stop(force) {
this.session.stopped = force ? FORCED_STOP : STOP;
},
/**
* run the recognizers!
* called by the inputHandler function on every movement of the pointers (touches)
* it walks through all the recognizers and tries to detect the gesture that is being made
* @param {Object} inputData
*/
recognize: function recognize(inputData) {
var session = this.session;
if (session.stopped) {
return;
}
// run the touch-action polyfill
this.touchAction.preventDefaults(inputData);
var recognizer;
var recognizers = this.recognizers;
// this holds the recognizer that is being recognized.
// so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
// if no recognizer is detecting a thing, it is set to `null`
var curRecognizer = session.curRecognizer;
// reset when the last recognizer is recognized
// or when we're in a new session
if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
curRecognizer = session.curRecognizer = null;
}
var i = 0;
while (i < recognizers.length) {
recognizer = recognizers[i];
// find out if we are allowed try to recognize the input for this one.
// 1. allow if the session is NOT forced stopped (see the .stop() method)
// 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
// that is being recognized.
// 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
// this can be setup with the `recognizeWith()` method on the recognizer.
if (session.stopped !== FORCED_STOP && (!curRecognizer || recognizer == curRecognizer || recognizer.canRecognizeWith(curRecognizer))) {
recognizer.recognize(inputData);
} else {
recognizer.reset();
}
// if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
// current active recognizer. but only if we don't already have an active recognizer
if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
curRecognizer = session.curRecognizer = recognizer;
}
i++;
}
},
/**
* get a recognizer by its event name.
* @param {Recognizer|String} recognizer
* @returns {Recognizer|Null}
*/
get: function get(recognizer) {
if (recognizer instanceof Recognizer) {
return recognizer;
}
var recognizers = this.recognizers;
for (var i = 0; i < recognizers.length; i++) {
if (recognizers[i].options.event == recognizer) {
return recognizers[i];
}
}
return null;
},
/**
* add a recognizer to the manager
* existing recognizers with the same event name will be removed
* @param {Recognizer} recognizer
* @returns {Recognizer|Manager}
*/
add: function add(recognizer) {
if (invokeArrayArg(recognizer, 'add', this)) {
return this;
}
// remove existing
var existing = this.get(recognizer.options.event);
if (existing) {
this.remove(existing);
}
this.recognizers.push(recognizer);
recognizer.manager = this;
this.touchAction.update();
return recognizer;
},
/**
* remove a recognizer by name or instance
* @param {Recognizer|String} recognizer
* @returns {Manager}
*/
remove: function remove(recognizer) {
if (invokeArrayArg(recognizer, 'remove', this)) {
return this;
}
var recognizers = this.recognizers;
recognizer = this.get(recognizer);
recognizers.splice(inArray(recognizers, recognizer), 1);
this.touchAction.update();
return this;
},
/**
* bind event
* @param {String} events
* @param {Function} handler
* @returns {EventEmitter} this
*/
on: function on(events, handler) {
var handlers = this.handlers;
each(splitStr(events), function (event) {
handlers[event] = handlers[event] || [];
handlers[event].push(handler);
});
return this;
},
/**
* unbind event, leave emit blank to remove all handlers
* @param {String} events
* @param {Function} [handler]
* @returns {EventEmitter} this
*/
off: function off(events, handler) {
var handlers = this.handlers;
each(splitStr(events), function (event) {
if (!handler) {
delete handlers[event];
} else {
handlers[event].splice(inArray(handlers[event], handler), 1);
}
});
return this;
},
/**
* emit event to the listeners
* @param {String} event
* @param {Object} data
*/
emit: function emit(event, data) {
// we also want to trigger dom events
if (this.options.domEvents) {
triggerDomEvent(event, data);
}
// no handlers, so skip it all
var handlers = this.handlers[event] && this.handlers[event].slice();
if (!handlers || !handlers.length) {
return;
}
data.type = event;
data.preventDefault = function () {
data.srcEvent.preventDefault();
};
var i = 0;
while (i < handlers.length) {
handlers[i](data);
i++;
}
},
/**
* destroy the manager and unbinds all events
* it doesn't unbind dom events, that is the user own responsibility
*/
destroy: function destroy() {
this.element && toggleCssProps(this, false);
this.handlers = {};
this.session = {};
this.input.destroy();
this.element = null;
}
};extend(Hammer, {
INPUT_START: INPUT_START,
INPUT_MOVE: INPUT_MOVE,
INPUT_END: INPUT_END,
INPUT_CANCEL: INPUT_CANCEL,
STATE_POSSIBLE: STATE_POSSIBLE,
STATE_BEGAN: STATE_BEGAN,
STATE_CHANGED: STATE_CHANGED,
STATE_ENDED: STATE_ENDED,
STATE_RECOGNIZED: STATE_RECOGNIZED,
STATE_CANCELLED: STATE_CANCELLED,
STATE_FAILED: STATE_FAILED,
DIRECTION_NONE: DIRECTION_NONE,
DIRECTION_LEFT: DIRECTION_LEFT,
DIRECTION_RIGHT: DIRECTION_RIGHT,
DIRECTION_UP: DIRECTION_UP,
DIRECTION_DOWN: DIRECTION_DOWN,
DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
DIRECTION_VERTICAL: DIRECTION_VERTICAL,
DIRECTION_ALL: DIRECTION_ALL,
Manager: Manager,
Input: Input,
TouchAction: TouchAction,
TouchInput: TouchInput,
MouseInput: MouseInput,
PointerEventInput: PointerEventInput,
TouchMouseInput: TouchMouseInput,
SingleTouchInput: SingleTouchInput,
Recognizer: Recognizer,
AttrRecognizer: AttrRecognizer,
Tap: TapRecognizer,
Pan: PanRecognizer,
Swipe: SwipeRecognizer,
Pinch: PinchRecognizer,
Rotate: RotateRecognizer,
Press: PressRecognizer,
on: addEventListeners,
off: removeEventListeners,
each: each,
merge: merge,
extend: extend,
inherit: inherit,
bindFn: bindFn,
prefixed: prefixed
});
// attach to window for angular2 gesture listeners
window.Hammer = Hammer;
_export('Hammer', Hammer);
}
};
});
System.register('ionic/gestures/slide-edge-gesture', ['./slide-gesture', '../util/util', '../util/dom'], function (_export) {
'use strict';
var SlideGesture, defaults, windowDimensions, SlideEdgeGesture;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
return {
setters: [function (_slideGesture) {
SlideGesture = _slideGesture.SlideGesture;
}, function (_utilUtil) {
defaults = _utilUtil.defaults;
}, function (_utilDom) {
windowDimensions = _utilDom.windowDimensions;
}],
execute: function () {
SlideEdgeGesture = (function (_SlideGesture) {
_inherits(SlideEdgeGesture, _SlideGesture);
function SlideEdgeGesture(element) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, SlideEdgeGesture);
defaults(opts, {
edge: 'left',
threshold: 50
});
_get(Object.getPrototypeOf(SlideEdgeGesture.prototype), 'constructor', this).call(this, element, opts);
// Can check corners through use of eg 'left top'
this.edges = opts.edge.split(' ');
this.threshold = opts.threshold;
}
_createClass(SlideEdgeGesture, [{
key: 'canStart',
value: function canStart(ev) {
var _this = this;
this._d = this.getContainerDimensions();
return this.edges.every(function (edge) {
return _this._checkEdge(edge, ev.center);
});
}
}, {
key: 'getContainerDimensions',
value: function getContainerDimensions() {
return {
left: 0,
top: 0,
width: windowDimensions().width,
height: windowDimensions().height
};
}
}, {
key: '_checkEdge',
value: function _checkEdge(edge, pos) {
switch (edge) {
case 'left':
return pos.x <= this._d.left + this.threshold;
case 'right':
return pos.x >= this._d.width - this.threshold;
case 'top':
return pos.y <= this._d.top + this.threshold;
case 'bottom':
return pos.y >= this._d.height - this.threshold;
}
}
}]);
return SlideEdgeGesture;
})(SlideGesture);
_export('SlideEdgeGesture', SlideEdgeGesture);
}
};
});
System.register('ionic/gestures/slide-gesture', ['./drag-gesture', '../util'], function (_export) {
'use strict';
var DragGesture, util, SlideGesture;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
return {
setters: [function (_dragGesture) {
DragGesture = _dragGesture.DragGesture;
}, function (_util) {
util = _util;
}],
execute: function () {
SlideGesture = (function (_DragGesture) {
_inherits(SlideGesture, _DragGesture);
function SlideGesture(element) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, SlideGesture);
_get(Object.getPrototypeOf(SlideGesture.prototype), 'constructor', this).call(this, element, opts);
this.element = element;
}
/*
* Get the min and max for the slide. pageX/pageY.
* Only called on dragstart.
*/
_createClass(SlideGesture, [{
key: 'getSlideBoundaries',
value: function getSlideBoundaries(slide, ev) {
return {
min: 0,
max: this.element.offsetWidth
};
}
/*
* Get the element's pos when the drag starts.
* For example, an open side menu starts at 100% and a closed
* sidemenu starts at 0%.
*/
}, {
key: 'getElementStartPos',
value: function getElementStartPos(slide, ev) {
return 0;
}
}, {
key: 'canStart',
value: function canStart() {
return true;
}
}, {
key: 'onDragStart',
value: function onDragStart(ev) {
var _this = this;
if (!this.canStart(ev)) return false;
this.slide = {};
var promise = this.onSlideBeforeStart(this.slide, ev) || Promise.resolve();
promise.then(function () {
var _getSlideBoundaries = _this.getSlideBoundaries(_this.slide, ev);
var min = _getSlideBoundaries.min;
var max = _getSlideBoundaries.max;
_this.slide.min = min;
_this.slide.max = max;
_this.slide.elementStartPos = _this.getElementStartPos(_this.slide, ev);
_this.slide.pointerStartPos = ev.center[_this.direction];
_this.slide.started = true;
_this.onSlideStart(_this.slide, ev);
})['catch'](function () {
_this.slide = null;
});
}
}, {
key: 'onDrag',
value: function onDrag(ev) {
if (!this.slide || !this.slide.started) return;
this.slide.pos = ev.center[this.direction];
this.slide.distance = util.clamp(this.slide.min, this.slide.pos - this.slide.pointerStartPos + this.slide.elementStartPos, this.slide.max);
this.slide.delta = this.slide.pos - this.slide.pointerStartPos;
this.onSlide(this.slide, ev);
}
}, {
key: 'onDragEnd',
value: function onDragEnd(ev) {
if (!this.slide || !this.slide.started) return;
this.onSlideEnd(this.slide, ev);
this.slide = null;
}
}, {
key: 'onSlideBeforeStart',
value: function onSlideBeforeStart() {}
}, {
key: 'onSlideStart',
value: function onSlideStart() {}
}, {
key: 'onSlide',
value: function onSlide() {}
}, {
key: 'onSlideEnd',
value: function onSlideEnd() {}
}]);
return SlideGesture;
})(DragGesture);
_export('SlideGesture', SlideGesture);
}
};
});
System.register('ionic/util/click-block', [], function (_export) {
'use strict';
var CSS_CLICK_BLOCK, DEFAULT_EXPIRE, cbEle, fallbackTimerId, isShowing, ClickBlock;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _show(expire) {
clearTimeout(fallbackTimerId);
fallbackTimerId = setTimeout(hide, expire || DEFAULT_EXPIRE);
if (!isShowing) {
cbEle.classList.add(CSS_CLICK_BLOCK);
isShowing = true;
}
}
function hide() {
clearTimeout(fallbackTimerId);
if (isShowing) {
cbEle.classList.remove(CSS_CLICK_BLOCK);
isShowing = false;
}
}
return {
setters: [],
execute: function () {
CSS_CLICK_BLOCK = 'click-block-active';
DEFAULT_EXPIRE = 330;
cbEle = undefined;
fallbackTimerId = undefined;
isShowing = false;
/**
* @private
*/
ClickBlock = (function () {
function ClickBlock() {
_classCallCheck(this, ClickBlock);
}
_createClass(ClickBlock, [{
key: 'enable',
value: function enable() {
cbEle = document.createElement('click-block');
document.body.appendChild(cbEle);
cbEle.addEventListener('touchmove', function (ev) {
ev.preventDefault();
ev.stopPropagation();
});
this._enabled = true;
}
}, {
key: 'show',
value: function show(shouldShow, expire) {
if (this._enabled) {
if (shouldShow) {
_show(expire);
} else {
hide();
}
}
}
}]);
return ClickBlock;
})();
_export('ClickBlock', ClickBlock);
}
};
});
System.register('ionic/util/dom', [], function (_export) {
// requestAnimationFrame is polyfilled for old Android
// within the web-animations polyfill
'use strict';
var raf, CSS, matchesFn, dimensionCache, dimensionIds;
_export('rafFrames', rafFrames);
_export('transitionEnd', transitionEnd);
_export('animationStart', animationStart);
_export('animationEnd', animationEnd);
_export('ready', ready);
_export('windowLoad', windowLoad);
_export('pointerCoord', pointerCoord);
_export('hasPointerMoved', hasPointerMoved);
_export('isActive', isActive);
_export('hasFocus', hasFocus);
_export('isTextInput', isTextInput);
_export('hasFocusedTextInput', hasFocusedTextInput);
_export('closest', closest);
/**
* Get the element offsetWidth and offsetHeight. Values are cached
* to reduce DOM reads. Cache is cleared on a window resize.
* @param {TODO} ele TODO
*/
_export('removeElement', removeElement);
_export('getDimensions', getDimensions);
_export('windowDimensions', windowDimensions);
_export('flushDimensionCache', flushDimensionCache);
_export('parentOffsetEl', parentOffsetEl);
/**
* Get the current coordinates of the element, relative to the document.
* Read-only equivalent of [jQuery's offset function](http://api.jquery.com/offset/).
* @param {element} element The element to get the offset of.
* @returns {object} Returns an object containing the properties top, left, width and height.
*/
_export('position', position);
_export('offset', offset);
function rafFrames(framesToWait, callback) {
framesToWait = Math.ceil(framesToWait);
if (framesToWait < 2) {
raf(callback);
} else {
setTimeout(function () {
raf(callback);
}, (framesToWait - 1) * 17);
}
}
function transitionEnd(el) {
return cssPromise(el, CSS.transitionEnd);
}
function animationStart(el, animationName) {
return cssPromise(el, CSS.animationStart, animationName);
}
function animationEnd(el, animationName) {
return cssPromise(el, CSS.animationEnd, animationName);
}
function cssPromise(el, eventNames, animationName) {
return new Promise(function (resolve) {
eventNames.split(' ').forEach(function (eventName) {
el.addEventListener(eventName, onEvent);
});
function onEvent(ev) {
if (ev.animationName && animationName) {
// do not resolve if a bubbled up ev.animationName
// is not the same as the passed in animationName arg
if (ev.animationName !== animationName) {
return;
}
} else if (ev.target !== el) {
// do not resolve if the event's target element is not
// the same as the element the listener was added to
return;
}
ev.stopPropagation();
eventNames.split(' ').forEach(function (eventName) {
el.removeEventListener(eventName, onEvent);
});
resolve(ev);
}
});
}
function ready(callback) {
var promise = null;
if (!callback) {
// a callback wasn't provided, so let's return a promise instead
promise = new Promise(function (resolve) {
callback = resolve;
});
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
callback();
} else {
(function () {
var completed = function completed() {
document.removeEventListener('DOMContentLoaded', completed, false);
window.removeEventListener('load', completed, false);
callback();
};
document.addEventListener('DOMContentLoaded', completed, false);
window.addEventListener('load', completed, false);
})();
}
return promise;
}
function windowLoad(callback) {
var promise = null;
if (!callback) {
// a callback wasn't provided, so let's return a promise instead
promise = new Promise(function (resolve) {
callback = resolve;
});
}
if (document.readyState === 'complete') {
callback();
} else {
(function () {
var completed = function completed() {
window.removeEventListener('load', completed, false);
callback();
};
window.addEventListener('load', completed, false);
})();
}
return promise;
}
function pointerCoord(ev) {
// get coordinates for either a mouse click
// or a touch depending on the given event
var c = { x: 0, y: 0 };
if (ev) {
var touches = ev.touches && ev.touches.length ? ev.touches : [ev];
var e = ev.changedTouches && ev.changedTouches[0] || touches[0];
if (e) {
c.x = e.clientX || e.pageX || 0;
c.y = e.clientY || e.pageY || 0;
}
}
return c;
}
function hasPointerMoved(threshold, startCoord, endCoord) {
return startCoord && endCoord && (Math.abs(startCoord.x - endCoord.x) > threshold || Math.abs(startCoord.y - endCoord.y) > threshold);
}
function isActive(ele) {
return !!(ele && document.activeElement === ele);
}
function hasFocus(ele) {
return isActive(ele) && ele.parentElement.querySelector(':focus') === ele;
}
function isTextInput(ele) {
return !!ele && (ele.tagName == 'TEXTAREA' || ele.contentEditable === 'true' || ele.tagName == 'INPUT' && !/^(radio|checkbox|range|file|submit|reset|color|image|button)$/i.test(ele.type));
}
function hasFocusedTextInput() {
var ele = document.activeElement;
if (isTextInput(ele)) {
return ele.parentElement.querySelector(':focus') === ele;
}
return false;
}
function closest(ele, selector, checkSelf) {
if (ele && matchesFn) {
// traverse parents
ele = checkSelf ? ele : ele.parentElement;
while (ele !== null) {
if (ele[matchesFn](selector)) {
return ele;
}
ele = ele.parentElement;
}
}
return null;
}
function removeElement(ele) {
ele && ele.parentNode && ele.parentNode.removeChild(ele);
}
function getDimensions(ion, ele) {
if (!ion._dimId) {
ion._dimId = ++dimensionIds;
if (ion._dimId % 1000 === 0) {
// periodically flush dimensions
flushDimensionCache();
}
}
var dimensions = dimensionCache[ion._dimId];
if (!dimensions) {
var _ele = ion.getNativeElement();
// make sure we got good values before caching
if (_ele.offsetWidth && _ele.offsetHeight) {
dimensions = dimensionCache[ion._dimId] = {
width: _ele.offsetWidth,
height: _ele.offsetHeight,
left: _ele.offsetLeft,
top: _ele.offsetTop
};
} else {
// do not cache bad values
return { width: 0, height: 0, left: 0, top: 0 };
}
}
return dimensions;
}
function windowDimensions() {
if (!dimensionCache.win) {
// make sure we got good values before caching
if (window.innerWidth && window.innerHeight) {
dimensionCache.win = {
width: window.innerWidth,
height: window.innerHeight
};
} else {
// do not cache bad values
return { width: 0, height: 0 };
}
}
return dimensionCache.win;
}
function flushDimensionCache() {
dimensionCache = {};
}
function isStaticPositioned(element) {
return (element.style.position || 'static') === 'static';
}
/**
* returns the closest, non-statically positioned parentOffset of a given element
* @param element
*/
function parentOffsetEl(element) {
var offsetParent = element.offsetParent || document;
while (offsetParent && offsetParent !== document && isStaticPositioned(offsetParent)) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent || document;
}
/**
* Get the current coordinates of the element, relative to the offset parent.
* Read-only equivalent of [jQuery's position function](http://api.jquery.com/position/).
* @param {element} element The element to get the position of.
* @returns {object} Returns an object containing the properties top, left, width and height.
*/
function position(element) {
var elBCR = offset(element);
var offsetParentBCR = { top: 0, left: 0 };
var offsetParentEl = parentOffsetEl(element);
if (offsetParentEl != document) {
offsetParentBCR = offset(offsetParentEl);
offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
}
var boundingClientRect = element.getBoundingClientRect();
return {
width: boundingClientRect.width || element.offsetWidth,
height: boundingClientRect.height || element.offsetHeight,
top: elBCR.top - offsetParentBCR.top,
left: elBCR.left - offsetParentBCR.left
};
}
function offset(element) {
var boundingClientRect = element.getBoundingClientRect();
return {
width: boundingClientRect.width || element.offsetWidth,
height: boundingClientRect.height || element.offsetHeight,
top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft)
};
}
return {
setters: [],
execute: function () {
raf = window.requestAnimationFrame;
_export('raf', raf);
CSS = {};
_export('CSS', CSS);
(function () {
// transform
var i,
keys = ['webkitTransform', 'transform', '-webkit-transform', 'webkit-transform', '-moz-transform', 'moz-transform', 'MozTransform', 'mozTransform', 'msTransform'];
for (i = 0; i < keys.length; i++) {
if (document.documentElement.style[keys[i]] !== undefined) {
CSS.transform = keys[i];
break;
}
}
// transition
keys = ['webkitTransition', 'mozTransition', 'msTransition', 'transition'];
for (i = 0; i < keys.length; i++) {
if (document.documentElement.style[keys[i]] !== undefined) {
CSS.transition = keys[i];
break;
}
}
// The only prefix we care about is webkit for transitions.
var isWebkit = CSS.transition.indexOf('webkit') > -1;
CSS.prefix = isWebkit ? '-webkit-' : '';
// transition duration
CSS.transitionDuration = (isWebkit ? '-webkit-' : '') + 'transition-duration';
// To be sure transitionend works everywhere, include *both* the webkit and non-webkit events
CSS.transitionEnd = (isWebkit ? 'webkitTransitionEnd ' : '') + 'transitionend';
})();
if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
CSS.animation = 'WebkitAnimation';
CSS.animationStart = 'webkitAnimationStart animationstart';
CSS.animationEnd = 'webkitAnimationEnd animationend';
} else {
CSS.animation = 'animation';
CSS.animationStart = 'animationstart';
CSS.animationEnd = 'animationend';
}
matchesFn = undefined;
['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector'].some(function (fn) {
if (typeof document.documentElement[fn] == 'function') {
matchesFn = fn;
}
});
dimensionCache = {};
dimensionIds = 0;
;
}
};
});
System.register("ionic/util/events", ["angular2/core"], function (_export) {
/**
* Events is a pub/sub style event system for sending and responding to application-level
* events across your app.
* @usage
* ```ts
* // first page (publish an event when a user is created)
* function createUser(user) {
* console.log('User created!')
* events.publish('user:created', user);
* }
*
* // second page (listen for the user created event)
* events.subscribe('user:created', (user) => {
* console.log('Welcome', user);
* });
*
* ```
*/
"use strict";
var Injectable, __decorate, __metadata, Events;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Injectable = _angular2Core.Injectable;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Events = (function () {
function Events() {
_classCallCheck(this, Events);
this.channels = [];
}
/**
* Subscribe to an event topic. Events that get posted to that topic
* will trigger the provided handler.
*
* @param topic the topic to subscribe to
* @param handler the event handler
*/
_createClass(Events, [{
key: "subscribe",
value: function subscribe(topic) {
var _this = this;
if (!this.channels[topic]) {
this.channels[topic] = [];
}
for (var _len = arguments.length, handlers = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
handlers[_key - 1] = arguments[_key];
}
handlers.forEach(function (handler) {
_this.channels[topic].push(handler);
});
}
/**
* Unsubscribe from the given topic. Your handler will
* no longer receive events published to this topic.
*
* @param topic the topic to unsubscribe from
* @param handler the event handler
*
* @return true if a handler was removed
*/
}, {
key: "unsubscribe",
value: function unsubscribe(topic, handler) {
var t = this.channels[topic];
if (!t) {
// Wasn't found, wasn't removed
return false;
}
if (!handler) {
// Remove all handlers for this topic
delete this.channels[topic];
return true;
}
// We need to find and remove a specific handler
var i = t.indexOf(handler);
if (i < 0) {
// Wasn't found, wasn't removed
return false;
}
t.splice(i, 1);
// If the channel is empty now, remove it from the channel map
if (!t.length) {
delete this.channels[topic];
}
return true;
}
/**
* Publish an event to the given topic.
*
* @param topic the topic to publish to
* @param eventData the data to send as the event
*/
}, {
key: "publish",
value: function publish(topic) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
var t = this.channels[topic];
if (!t) {
return null;
}
var responses = [];
t.forEach(function (handler) {
responses.push(handler(args));
});
return responses;
}
}]);
return Events;
})();
_export("Events", Events);
_export("Events", Events = __decorate([Injectable(), __metadata('design:paramtypes', [])], Events));
}
};
});
System.register('ionic/util/feature-detect', [], function (_export) {
'use strict';
var FeatureDetect, featureDetects;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
return {
setters: [],
execute: function () {
FeatureDetect = (function () {
function FeatureDetect() {
_classCallCheck(this, FeatureDetect);
}
_createClass(FeatureDetect, [{
key: 'run',
value: function run(window, document) {
this._results = {};
for (var _name in featureDetects) {
this._results[_name] = featureDetects[_name](window, document, document.body);
}
}
}, {
key: 'has',
value: function has(featureName) {
return !!this._results[featureName];
}
}], [{
key: 'add',
value: function add(name, fn) {
featureDetects[name] = fn;
}
}]);
return FeatureDetect;
})();
_export('FeatureDetect', FeatureDetect);
featureDetects = {};
// FeatureDetect.add('sticky', function(window, document) {
// // css position sticky
// let ele = document.createElement('div');
// ele.style.cssText = 'position:-webkit-sticky;position:sticky';
// return ele.style.position.indexOf('sticky') > -1;
// });
FeatureDetect.add('hairlines', function (window, document, body) {
/**
* Hairline Shim
* Add the "hairline" CSS class name to the body tag
* if the browser supports subpixels.
*/
var canDo = false;
if (window.devicePixelRatio >= 2) {
var hairlineEle = document.createElement('div');
hairlineEle.style.border = '.5px solid transparent';
body.appendChild(hairlineEle);
if (hairlineEle.offsetHeight === 1) {
body.classList.add('hairlines');
canDo = true;
}
body.removeChild(hairlineEle);
}
return canDo;
});
}
};
});
System.register("ionic/util/form", ["angular2/core"], function (_export) {
/**
* The Input component is used to focus text input elements.
*
* @usage
* ```html
*
* Name
*
*
* ```
*/
"use strict";
var Injectable, __decorate, __metadata, Form;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Injectable = _angular2Core.Injectable;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Form = (function () {
function Form() {
_classCallCheck(this, Form);
this._inputs = [];
this._ids = -1;
this._focused = null;
this.focusCtrl(document);
}
_createClass(Form, [{
key: "register",
value: function register(input) {
this._inputs.push(input);
}
}, {
key: "deregister",
value: function deregister(input) {
var index = this._inputs.indexOf(input);
if (index > -1) {
this._inputs.splice(index, 1);
}
if (input === this._focused) {
this._focused = null;
}
}
}, {
key: "focusCtrl",
value: function focusCtrl(document) {
// raw DOM fun
var focusCtrl = document.createElement('focus-ctrl');
focusCtrl.setAttribute('aria-hidden', true);
this._blur = document.createElement('button');
this._blur.tabIndex = -1;
focusCtrl.appendChild(this._blur);
document.body.appendChild(focusCtrl);
}
}, {
key: "focusOut",
value: function focusOut() {
console.debug('focusOut');
document.activeElement && document.activeElement.blur();
this._blur.focus();
}
}, {
key: "setAsFocused",
value: function setAsFocused(input) {
this._focused = input;
}
/**
* Focuses the next input element, if it exists.
*/
}, {
key: "focusNext",
value: function focusNext(currentInput) {
console.debug('focusNext');
var index = this._inputs.indexOf(currentInput);
if (index > -1 && index + 1 < this._inputs.length) {
var nextInput = this._inputs[index + 1];
if (nextInput !== this._focused) {
return nextInput.initFocus();
}
}
index = this._inputs.indexOf(this._focused);
if (index > 0) {
var previousInput = this._inputs[index - 1];
if (previousInput) {
previousInput.initFocus();
}
}
}
}, {
key: "nextId",
value: function nextId() {
return ++this._ids;
}
}]);
return Form;
})();
_export("Form", Form);
_export("Form", Form = __decorate([Injectable(), __metadata('design:paramtypes', [])], Form));
}
};
});
System.register("ionic/util/keyboard", ["angular2/core", "../config/config", "./form", "./dom"], function (_export) {
/**
* @name Keyboard
* @description
* The `Keyboard` class allows you to work with the keyboard events provide by the Ionic keyboard plugin.
*
* @usage
* ```ts
* export class MyClass{
* constructor(keyboard: Keyboard){
* this.keyboard = keyboard;
* }
* }
*
* ```
*/
"use strict";
var Injectable, NgZone, Config, Form, hasFocusedTextInput, raf, rafFrames, __decorate, __metadata, Keyboard, KEYBOARD_CLOSE_POLLING, _a, _b, _c;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Injectable = _angular2Core.Injectable;
NgZone = _angular2Core.NgZone;
}, function (_configConfig) {
Config = _configConfig.Config;
}, function (_form) {
Form = _form.Form;
}, function (_dom) {
hasFocusedTextInput = _dom.hasFocusedTextInput;
raf = _dom.raf;
rafFrames = _dom.rafFrames;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Keyboard = (function () {
function Keyboard(config, form, zone) {
var _this = this;
_classCallCheck(this, Keyboard);
this.form = form;
this.zone = zone;
zone.runOutsideAngular(function () {
_this.focusOutline(config.get('focusOutline'), document);
});
}
/**
* Chech to see if the keyboard is open or not.
*
* ```ts
* export class MyClass{
* constructor(keyboard: Keyboard){
* this.keyboard = keyboard;
* }
* keyboardCheck(){
* setTimeout(() => console.log('is the keyboard open ', this.keyboard.isOpen()));
* }
* }
*
* ```
*
* @return {Bool} returns a true or flase value if the keyboard is open or not
*/
_createClass(Keyboard, [{
key: "isOpen",
value: function isOpen() {
return hasFocusedTextInput();
}
/**
* When the keyboard is closed, call any methods you want
*
* ```ts
* export class MyClass{
* constructor(keyboard: Keyboard){
* this.keyboard = keyboard;
* this.keyboard.onClose(this.closeCallback);
* }
* closeCallback(){
* // call what ever functionality you want on keyboard close
* console.log('Closing time");
* }
* }
*
* ```
* @param {Function} callback method you want to call when the keyboard has been closed
* @return {Function} returns a callback that gets fired when the keyboard is closed
*/
}, {
key: "onClose",
value: function onClose(callback) {
var pollingInternval = arguments.length <= 1 || arguments[1] === undefined ? KEYBOARD_CLOSE_POLLING : arguments[1];
console.debug('keyboard onClose');
var self = this;
var checks = 0;
var promise = null;
if (!callback) {
// a callback wasn't provided, so let's return a promise instead
promise = new Promise(function (resolve) {
callback = resolve;
});
}
self.zone.runOutsideAngular(function () {
function checkKeyboard() {
console.debug('keyboard isOpen', self.isOpen(), checks);
if (!self.isOpen() || checks > 100) {
rafFrames(30, function () {
self.zone.run(function () {
console.debug('keyboard closed');
callback();
});
});
} else {
setTimeout(checkKeyboard, pollingInternval);
}
checks++;
}
setTimeout(checkKeyboard, pollingInternval);
});
return promise;
}
/**
* Progamatically close they keyboard
*
*/
}, {
key: "close",
value: function close() {
var _this2 = this;
console.debug('keyboard close()');
raf(function () {
if (hasFocusedTextInput()) {
// only focus out when a text input has focus
_this2.form.focusOut();
}
});
}
/**
* @private
*/
}, {
key: "focusOutline",
value: function focusOutline(setting, document) {
/* Focus Outline
* --------------------------------------------------
* By default, when a keydown event happens from a tab key, then
* the 'focus-outline' css class is added to the body element
* so focusable elements have an outline. On a mousedown or
* touchstart event, then the 'focus-outline' css class is removed.
*
* Config default overrides:
* focusOutline: true - Always add the focus-outline
* focusOutline: false - Do not add the focus-outline
*/
var self = this;
var isKeyInputEnabled = false;
function cssClass() {
raf(function () {
document.body.classList[isKeyInputEnabled ? 'add' : 'remove']('focus-outline');
});
}
if (setting === true) {
isKeyInputEnabled = true;
return cssClass();
} else if (setting === false) {
return;
}
// default is to add the focus-outline when the tab key is used
function keyDown(ev) {
if (!isKeyInputEnabled && ev.keyCode == 9) {
isKeyInputEnabled = true;
enableKeyInput();
}
}
function pointerDown() {
isKeyInputEnabled = false;
enableKeyInput();
}
function enableKeyInput() {
cssClass();
self.zone.runOutsideAngular(function () {
document.removeEventListener('mousedown', pointerDown);
document.removeEventListener('touchstart', pointerDown);
if (isKeyInputEnabled) {
document.addEventListener('mousedown', pointerDown);
document.addEventListener('touchstart', pointerDown);
}
});
}
document.addEventListener('keydown', keyDown);
}
}]);
return Keyboard;
})();
_export("Keyboard", Keyboard);
_export("Keyboard", Keyboard = __decorate([Injectable(), __metadata('design:paramtypes', [typeof (_a = typeof Config !== 'undefined' && Config) === 'function' && _a || Object, typeof (_b = typeof Form !== 'undefined' && Form) === 'function' && _b || Object, typeof (_c = typeof NgZone !== 'undefined' && NgZone) === 'function' && _c || Object])], Keyboard));
KEYBOARD_CLOSE_POLLING = 150;
}
};
});
System.register('ionic/util/util', [], function (_export) {
// Simple noop function
'use strict';
var isBoolean, isString, isNumber, isFunction, isDefined, isUndefined, isBlank, isObject, isArray, isTrueProperty, uid, array;
_export('noop', noop);
/**
* Extend the destination with an arbitrary number of other objects.
* @param dst the destination
* @param ... the param objects
*/
_export('clamp', clamp);
/**
* Do a deep extend (merge).
* @param dst the destination
* @param ... the param objects
*/
_export('extend', extend);
_export('merge', merge);
/**
* Apply default arguments if they don't exist in
* the first object.
* @param the destination to apply defaults to.
*/
_export('debounce', debounce);
_export('defaults', defaults);
_export('pascalCaseToDashCase', pascalCaseToDashCase);
_export('nextUid', nextUid);
/**
* Throttle the given fun, only allowing it to be
* called at most every `wait` ms.
*/
_export('getQuerystring', getQuerystring);
_export('throttle', throttle);
function noop() {}
/**
* Given a min and max, restrict the given number
* to the range.
* @param min the minimum
* @param n the value
* @param max the maximum
*/
function clamp(min, n, max) {
return Math.max(min, Math.min(n, max));
}
function extend(dst) {
return _baseExtend(dst, [].slice.call(arguments, 1), false);
}
function merge(dst) {
return _baseExtend(dst, [].slice.call(arguments, 1), true);
}
function _baseExtend(dst, objs, deep) {
for (var i = 0, ii = objs.length; i < ii; ++i) {
var obj = objs[i];
if (!obj || !isObject(obj) && !isFunction(obj)) continue;
var keys = Object.keys(obj);
for (var j = 0, jj = keys.length; j < jj; j++) {
var key = keys[j];
var src = obj[key];
if (deep && isObject(src)) {
if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};
_baseExtend(dst[key], [src], true);
} else {
dst[key] = src;
}
}
}
return dst;
}
function debounce(func, wait, immediate) {
var timeout, args, context, timestamp, result;
return function () {
context = this;
args = arguments;
timestamp = new Date();
var later = function later() {
var last = new Date() - timestamp;
if (last < wait) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) result = func.apply(context, args);
}
};
var callNow = immediate && !timeout;
if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) result = func.apply(context, args);
return result;
};
}
function defaults(dest) {
for (var i = arguments.length - 1; i >= 1; i--) {
var source = arguments[i] || {};
for (var key in source) {
if (source.hasOwnProperty(key) && !dest.hasOwnProperty(key)) {
dest[key] = source[key];
}
}
}
return dest;
}
/**
* Convert a string in the format thisIsAString to a slug format this-is-a-string
*/
function pascalCaseToDashCase() {
var str = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
return str.charAt(0).toLowerCase() + str.substring(1).replace(/[A-Z]/g, function (match) {
return '-' + match.toLowerCase();
});
}
function nextUid() {
return ++uid;
}
/**
* Grab the query string param value for the given key.
* @param key the key to look for
*/
function getQuerystring(url, key) {
var queryParams = {};
if (url) {
var startIndex = url.indexOf('?');
if (startIndex !== -1) {
var queries = url.slice(startIndex + 1).split('&');
queries.forEach(function (param) {
var split = param.split('=');
queryParams[split[0].toLowerCase()] = split[1].split('#')[0];
});
}
if (key) {
return queryParams[key] || '';
}
}
return queryParams;
}
function throttle(func, wait, options) {
var context, args, result;
var timeout = null;
var previous = 0;
options || (options = {});
var later = function later() {
previous = options.leading === false ? 0 : Date.now();
timeout = null;
result = func.apply(context, args);
};
return function () {
var now = Date.now();
if (!previous && options.leading === false) previous = now;
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0) {
clearTimeout(timeout);
timeout = null;
previous = now;
result = func.apply(context, args);
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
}
return {
setters: [],
execute: function () {
;
isBoolean = function isBoolean(val) {
return typeof val === 'boolean';
};
_export('isBoolean', isBoolean);
isString = function isString(val) {
return typeof val === 'string';
};
_export('isString', isString);
isNumber = function isNumber(val) {
return typeof val === 'number';
};
_export('isNumber', isNumber);
isFunction = function isFunction(val) {
return typeof val === 'function';
};
_export('isFunction', isFunction);
isDefined = function isDefined(val) {
return typeof val !== 'undefined';
};
_export('isDefined', isDefined);
isUndefined = function isUndefined(val) {
return typeof val === 'undefined';
};
_export('isUndefined', isUndefined);
isBlank = function isBlank(val) {
return val === undefined || val === null;
};
_export('isBlank', isBlank);
isObject = function isObject(val) {
return typeof val === 'object';
};
_export('isObject', isObject);
isArray = Array.isArray;
_export('isArray', isArray);
isTrueProperty = function isTrueProperty(val) {
return typeof val !== 'undefined' && val !== "false";
};
_export('isTrueProperty', isTrueProperty);
uid = 0;
array = {
find: function find(arr, cb) {
for (var i = 0, ii = arr.length; i < ii; i++) {
if (cb(arr[i], i)) return arr[i];
}
},
remove: function remove(arr, itemOrIndex) {
var index = -1;
if (isNumber(itemOrIndex)) {
index = itemOrIndex;
} else {
index = arr.indexOf(itemOrIndex);
}
if (index < 0) {
return false;
}
arr.splice(index, 1);
return true;
}
};
_export('array', array);
}
};
});
System.register("ionic/components/action-sheet/action-sheet", ["angular2/core", "angular2/common", "../nav/nav-controller", "../nav/view-controller", "../../config/config", "../icon/icon", "../../animations/animation"], function (_export) {
/**
* @name ActionSheet
* @description
* An Action Sheet is a dialog that lets the user choose from a set of
* options. It appears on top of the app's content, and must be manually
* dismissed by the user before they can resume interaction with the app.
* Dangerous (destructive) options are made obvious. There are easy
* ways to cancel out of the action sheet, such as tapping the backdrop or
* hitting the escape key on desktop.
*
* An action sheet is created from an array of `buttons`, with each button
* including properties for its `text`, and optionally a `style` and `handler`.
* If a handler returns `false` then the action sheet will not be dismissed. An
* action sheet can also optionally have a `title` and a `subTitle`.
*
* A button's `style` property can either be `destructive` or `cancel`. Buttons
* without a style property will have a default style for its platform. Buttons
* with the `cancel` style will always load as the bottom button, no matter where
* it shows up in the array. All other buttons will show up in the order they
* have been added to the `buttons` array. Note: We recommend that `destructive`
* buttons show be the first button in the array, making it the button on top.
*
* Its shorthand is to add all the action sheet's options from within the
* `ActionSheet.create(opts)` first argument. Otherwise the action sheet's
* instance has methods to add options, such as `setTitle()` or `addButton()`.
*
* @usage
* ```ts
* constructor(nav: NavController) {
* this.nav = nav;
* }
*
* presentActionSheet() {
* let actionSheet = ActionSheet.create({
* title: 'Modify your album',
* buttons: [
* {
* text: 'Destructive',
* style: 'destructive',
* handler: () => {
* console.log('Destructive clicked');
* }
* },
* {
* text: 'Archive',
* handler: () => {
* console.log('Archive clicked');
* }
* },
* {
* text: 'Cancel',
* style: 'cancel',
* handler: () => {
* console.log('Cancel clicked');
* }
* }
* ]
* });
*
* this.nav.present(actionSheet);
* }
* ```
*
* @demo /docs/v3/demos/action-sheet/
* @see {@link /docs/v3/components#action-sheets ActionSheet Component Docs}
*/
"use strict";
var Component, Renderer, NgFor, NgIf, NavParams, ViewController, Config, Icon, Animation, __decorate, __metadata, ActionSheet, ActionSheetCmp, ActionSheetSlideIn, ActionSheetSlideOut, ActionSheetMdSlideIn, ActionSheetMdSlideOut, _a, _b, _c, _d;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
return {
setters: [function (_angular2Core) {
Component = _angular2Core.Component;
Renderer = _angular2Core.Renderer;
}, function (_angular2Common) {
NgFor = _angular2Common.NgFor;
NgIf = _angular2Common.NgIf;
}, function (_navNavController) {
NavParams = _navNavController.NavParams;
}, function (_navViewController) {
ViewController = _navViewController.ViewController;
}, function (_configConfig) {
Config = _configConfig.Config;
}, function (_iconIcon) {
Icon = _iconIcon.Icon;
}, function (_animationsAnimation) {
Animation = _animationsAnimation.Animation;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
ActionSheet = (function (_ViewController) {
_inherits(ActionSheet, _ViewController);
function ActionSheet() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
_classCallCheck(this, ActionSheet);
opts.buttons = opts.buttons || [];
_get(Object.getPrototypeOf(ActionSheet.prototype), "constructor", this).call(this, ActionSheetCmp, opts);
this.viewType = 'action-sheet';
}
/**
* @private
*/
/**
* @private
*/
_createClass(ActionSheet, [{
key: "getTransitionName",
value: function getTransitionName(direction) {
var key = 'actionSheet' + (direction === 'back' ? 'Leave' : 'Enter');
return this._nav && this._nav.config.get(key);
}
/**
* @param {string} title Action sheet title
*/
}, {
key: "setTitle",
value: function setTitle(title) {
this.data.title = title;
}
/**
* @param {string} subTitle Action sheet subtitle
*/
}, {
key: "setSubTitle",
value: function setSubTitle(subTitle) {
this.data.subTitle = subTitle;
}
/**
* @param {Object} button Action sheet button
*/
}, {
key: "addButton",
value: function addButton(button) {
this.data.buttons.push(button);
}
/**
* @param {Object} opts Action sheet options
*/
}], [{
key: "create",
value: function create() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
return new ActionSheet(opts);
}
}]);
return ActionSheet;
})(ViewController);
_export("ActionSheet", ActionSheet);
ActionSheetCmp = (function () {
function ActionSheetCmp(_viewCtrl, _config, params, renderer) {
_classCallCheck(this, ActionSheetCmp);
this._viewCtrl = _viewCtrl;
this._config = _config;
this.d = params.data;
if (this.d.cssClass) {
renderer.setElementClass(elementRef, this.d.cssClass, true);
}
}
_createClass(ActionSheetCmp, [{
key: "click",
value: function click(button) {
var _this = this;
var shouldDismiss = true;
if (button.handler) {
// a handler has been provided, execute it
if (button.handler() === false) {
// if the return value of the handler is false then do not dismiss
shouldDismiss = false;
}
}
if (shouldDismiss) {
setTimeout(function () {
_this.dismiss();
}, this._config.get('pageTransitionDelay'));
}
}
}, {
key: "dismiss",
value: function dismiss() {
this._viewCtrl.dismiss();
}
}, {
key: "onPageLoaded",
value: function onPageLoaded() {
var _this2 = this;
// normalize the data
var buttons = [];
this.d.buttons.forEach(function (button) {
if (typeof button === 'string') {
button = { text: button };
}
if (!button.cssClass) {
button.cssClass = '';
}
if (button.style === 'cancel') {
_this2.d.cancelButton = button;
} else {
if (button.style === 'destructive') {
button.cssClass = (button.cssClass + ' ' || '') + 'action-sheet-destructive';
}
buttons.push(button);
}
});
this.d.buttons = buttons;
var self = this;
self.keyUp = function (ev) {
if (ev.keyCode === 27) {
console.debug('actionsheet escape');
self.dismiss();
}
};
document.addEventListener('keyup', this.keyUp);
}
}, {
key: "onPageDidLeave",
value: function onPageDidLeave() {
document.removeEventListener('keyup', this.keyUp);
}
}]);
return ActionSheetCmp;
})();
ActionSheetCmp = __decorate([Component({
selector: 'ion-action-sheet',
template: '' + '
' + '
' + '
' + '
{{d.title}}
' + '
{{d.subTitle}}
' + '' + '
' + '
' + '' + '
' + '
' + '
',
host: {
'role': 'dialog'
},
directives: [NgFor, NgIf, Icon]
}), __metadata('design:paramtypes', [typeof (_a = typeof ViewController !== 'undefined' && ViewController) === 'function' && _a || Object, typeof (_b = typeof Config !== 'undefined' && Config) === 'function' && _b || Object, typeof (_c = typeof NavParams !== 'undefined' && NavParams) === 'function' && _c || Object, typeof (_d = typeof Renderer !== 'undefined' && Renderer) === 'function' && _d || Object])], ActionSheetCmp);
ActionSheetSlideIn = (function (_Animation) {
_inherits(ActionSheetSlideIn, _Animation);
function ActionSheetSlideIn(enteringView, leavingView, opts) {
_classCallCheck(this, ActionSheetSlideIn);
_get(Object.getPrototypeOf(ActionSheetSlideIn.prototype), "constructor", this).call(this, null, opts);
var ele = enteringView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.action-sheet-wrapper'));
backdrop.fromTo('opacity', 0.01, 0.4);
wrapper.fromTo('translateY', '100%', '0%');
this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add([backdrop, wrapper]);
}
return ActionSheetSlideIn;
})(Animation);
Animation.register('action-sheet-slide-in', ActionSheetSlideIn);
ActionSheetSlideOut = (function (_Animation2) {
_inherits(ActionSheetSlideOut, _Animation2);
function ActionSheetSlideOut(enteringView, leavingView, opts) {
_classCallCheck(this, ActionSheetSlideOut);
_get(Object.getPrototypeOf(ActionSheetSlideOut.prototype), "constructor", this).call(this, null, opts);
var ele = leavingView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.action-sheet-wrapper'));
backdrop.fromTo('opacity', 0.4, 0);
wrapper.fromTo('translateY', '0%', '100%');
this.easing('cubic-bezier(.36,.66,.04,1)').duration(300).add([backdrop, wrapper]);
}
return ActionSheetSlideOut;
})(Animation);
Animation.register('action-sheet-slide-out', ActionSheetSlideOut);
ActionSheetMdSlideIn = (function (_Animation3) {
_inherits(ActionSheetMdSlideIn, _Animation3);
function ActionSheetMdSlideIn(enteringView, leavingView, opts) {
_classCallCheck(this, ActionSheetMdSlideIn);
_get(Object.getPrototypeOf(ActionSheetMdSlideIn.prototype), "constructor", this).call(this, null, opts);
var ele = enteringView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.action-sheet-wrapper'));
backdrop.fromTo('opacity', 0.01, 0.26);
wrapper.fromTo('translateY', '100%', '0%');
this.easing('cubic-bezier(.36,.66,.04,1)').duration(450).add([backdrop, wrapper]);
}
return ActionSheetMdSlideIn;
})(Animation);
Animation.register('action-sheet-md-slide-in', ActionSheetMdSlideIn);
ActionSheetMdSlideOut = (function (_Animation4) {
_inherits(ActionSheetMdSlideOut, _Animation4);
function ActionSheetMdSlideOut(enteringView, leavingView, opts) {
_classCallCheck(this, ActionSheetMdSlideOut);
_get(Object.getPrototypeOf(ActionSheetMdSlideOut.prototype), "constructor", this).call(this, null, opts);
var ele = leavingView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.action-sheet-wrapper'));
backdrop.fromTo('opacity', 0.26, 0);
wrapper.fromTo('translateY', '0%', '100%');
this.easing('cubic-bezier(.36,.66,.04,1)').duration(450).add([backdrop, wrapper]);
}
return ActionSheetMdSlideOut;
})(Animation);
Animation.register('action-sheet-md-slide-out', ActionSheetMdSlideOut);
}
};
});
System.register("ionic/components/alert/alert", ["angular2/core", "angular2/common", "../nav/nav-controller", "../nav/view-controller", "../../config/config", "../../animations/animation", "../../util/util"], function (_export) {
/**
* @name Alert
* @description
* An Alert is a dialog that presents users with either information, or used
* to receive information from the user using inputs. An alert appears on top
* of the app's content, and must be manually dismissed by the user before
* they can resume interaction with the app.
*
* An alert is created from an array of `buttons` and optionally an array of
* `inputs`. Each button includes properties for its `text`, and optionally a
* `handler`. If a handler returns `false` then the alert will not be dismissed.
* An alert can also optionally have a `title`, `subTitle` and `body`.
*
* All buttons will show up in the order they have been added to the `buttons`
* array, from left to right. Note: The right most button (the last one in the
* array) is the main button.
*
* Alerts can also include inputs whos data can be passed back to the app.
* Inputs can be used to prompt users for information.
*
* Its shorthand is to add all the alert's options from within the
* `Alert.create(opts)` first argument. Otherwise the alert's
* instance has methods to add options, such as `setTitle()` or `addButton()`.
*
* @usage
* ```ts
* constructor(nav: NavController) {
* this.nav = nav;
* }
*
* presentAlert() {
* let alert = Alert.create({
* title: 'Low battery',
* subTitle: '10% of battery remaining',
* buttons: ['Dismiss']
* });
* this.nav.present(alert);
* }
*
* presentConfirm() {
* let alert = Alert.create({
* title: 'Confirm purchase',
* body: 'Do you want to buy this book?',
* buttons: [
* {
* text: 'Cancel',
* handler: () => {
* console.log('Cancel clicked');
* }
* },
* {
* text: 'Buy',
* handler: () => {
* console.log('Buy clicked');
* }
* }
* ]
* });
* this.nav.present(alert);
* }
*
* presentPrompt() {
* let alert = Alert.create({
* title: 'Login',
* inputs: [
* {
* name: 'username',
* placeholder: 'Username'
* },
* {
* name: 'password',
* placeholder: 'Password',
* type: 'password'
* }
* ],
* buttons: [
* {
* text: 'Cancel',
* handler: data => {
* console.log('Cancel clicked');
* }
* },
* {
* text: 'Login',
* handler: data => {
* if (User.isValid(data.username, data.password)) {
* // logged in!
* } else {
* // invalid login
* return false;
* }
* }
* }
* ]
* });
* this.nav.present(alert);
* }
* ```
*
*/
"use strict";
var Component, ElementRef, Renderer, NgClass, NgIf, NgFor, NavParams, ViewController, Config, Animation, isDefined, __decorate, __metadata, Alert, AlertCmp, AlertPopIn, AlertPopOut, AlertMdPopIn, AlertMdPopOut, _a, _b, _c, _d, _e;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
return {
setters: [function (_angular2Core) {
Component = _angular2Core.Component;
ElementRef = _angular2Core.ElementRef;
Renderer = _angular2Core.Renderer;
}, function (_angular2Common) {
NgClass = _angular2Common.NgClass;
NgIf = _angular2Common.NgIf;
NgFor = _angular2Common.NgFor;
}, function (_navNavController) {
NavParams = _navNavController.NavParams;
}, function (_navViewController) {
ViewController = _navViewController.ViewController;
}, function (_configConfig) {
Config = _configConfig.Config;
}, function (_animationsAnimation) {
Animation = _animationsAnimation.Animation;
}, function (_utilUtil) {
isDefined = _utilUtil.isDefined;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Alert = (function (_ViewController) {
_inherits(Alert, _ViewController);
function Alert() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
_classCallCheck(this, Alert);
opts.inputs = opts.inputs || [];
opts.buttons = opts.buttons || [];
_get(Object.getPrototypeOf(Alert.prototype), "constructor", this).call(this, AlertCmp, opts);
this.viewType = 'alert';
}
/**
* @private
*/
/**
* @private
*/
_createClass(Alert, [{
key: "getTransitionName",
value: function getTransitionName(direction) {
var key = direction === 'back' ? 'alertLeave' : 'alertEnter';
return this._nav && this._nav.config.get(key);
}
/**
* @param {string} title Alert title
*/
}, {
key: "setTitle",
value: function setTitle(title) {
this.data.title = title;
}
/**
* @param {string} subTitle Alert subtitle
*/
}, {
key: "setSubTitle",
value: function setSubTitle(subTitle) {
this.data.subTitle = subTitle;
}
/**
* @param {string} body Alert body content
*/
}, {
key: "setBody",
value: function setBody(body) {
this.data.body = body;
}
/**
* @param {Object} input Alert input
*/
}, {
key: "addInput",
value: function addInput(input) {
this.data.inputs.push(input);
}
/**
* @param {Object} button Alert button
*/
}, {
key: "addButton",
value: function addButton(button) {
this.data.buttons.push(button);
}
/**
* @param {Object} opts Alert options
*/
}], [{
key: "create",
value: function create() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
return new Alert(opts);
}
}]);
return Alert;
})(ViewController);
_export("Alert", Alert);
AlertCmp = (function () {
function AlertCmp(_viewCtrl, _elementRef, _config, params, renderer) {
_classCallCheck(this, AlertCmp);
this._viewCtrl = _viewCtrl;
this._elementRef = _elementRef;
this._config = _config;
this.d = params.data;
if (this.d.cssClass) {
renderer.setElementClass(_elementRef, this.d.cssClass, true);
}
}
_createClass(AlertCmp, [{
key: "click",
value: function click(button) {
var _this = this;
var shouldDismiss = true;
if (button.handler) {
// a handler has been provided, execute it
// pass the handler the values from the inputs
if (button.handler(this.getValues()) === false) {
// if the return value of the handler is false then do not dismiss
shouldDismiss = false;
}
}
if (shouldDismiss) {
setTimeout(function () {
_this.dismiss();
}, this._config.get('pageTransitionDelay'));
}
}
}, {
key: "dismiss",
value: function dismiss() {
this._viewCtrl.dismiss(this.getValues());
}
}, {
key: "getValues",
value: function getValues() {
var values = {};
this.d.inputs.forEach(function (input) {
values[input.name] = input.value;
});
return values;
}
}, {
key: "onPageLoaded",
value: function onPageLoaded() {
// normalize the data
this.d.buttons = this.d.buttons.map(function (button) {
if (typeof button === 'string') {
return { text: button };
}
return button;
});
this.d.inputs = this.d.inputs.map(function (input, index) {
return {
name: isDefined(input.name) ? input.name : index,
placeholder: isDefined(input.placeholder) ? input.placeholder : '',
type: input.type || 'text',
value: isDefined(input.value) ? input.value : ''
};
});
var self = this;
self.keyUp = function (ev) {
if (ev.keyCode === 13) {
// enter
console.debug('alert enter');
var button = self.d.buttons[self.d.buttons.length - 1];
self.click(button);
} else if (ev.keyCode === 27) {
console.debug('alert escape');
self.dismiss();
}
};
document.addEventListener('keyup', this.keyUp);
}
}, {
key: "onPageDidEnter",
value: function onPageDidEnter() {
document.activeElement && document.activeElement.blur();
if (this.d.inputs.length) {
var firstInput = this._elementRef.nativeElement.querySelector('input');
if (firstInput) {
firstInput.focus();
}
}
}
}, {
key: "onPageDidLeave",
value: function onPageDidLeave() {
document.removeEventListener('keyup', this.keyUp);
}
}]);
return AlertCmp;
})();
AlertCmp = __decorate([Component({
selector: 'ion-alert',
template: '' + '
' + '
' + '
{{d.title}}
' + '
{{d.subTitle}}
' + '
' + '
{{d.body}}
' + '
' + '
' + '' + '
' + '
' + '
' + '' + '
' + '
',
host: {
'role': 'dialog'
},
directives: [NgClass, NgIf, NgFor]
}), __metadata('design:paramtypes', [typeof (_a = typeof ViewController !== 'undefined' && ViewController) === 'function' && _a || Object, typeof (_b = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _b || Object, typeof (_c = typeof Config !== 'undefined' && Config) === 'function' && _c || Object, typeof (_d = typeof NavParams !== 'undefined' && NavParams) === 'function' && _d || Object, typeof (_e = typeof Renderer !== 'undefined' && Renderer) === 'function' && _e || Object])], AlertCmp);
/**
* Animations for alerts
*/
AlertPopIn = (function (_Animation) {
_inherits(AlertPopIn, _Animation);
function AlertPopIn(enteringView, leavingView, opts) {
_classCallCheck(this, AlertPopIn);
_get(Object.getPrototypeOf(AlertPopIn.prototype), "constructor", this).call(this, null, opts);
var ele = enteringView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.alert-wrapper'));
wrapper.fromTo('opacity', '0.01', '1').fromTo('scale', '1.1', '1');
backdrop.fromTo('opacity', '0.01', '0.3');
this.easing('ease-in-out').duration(200).add(backdrop, wrapper);
}
return AlertPopIn;
})(Animation);
Animation.register('alert-pop-in', AlertPopIn);
AlertPopOut = (function (_Animation2) {
_inherits(AlertPopOut, _Animation2);
function AlertPopOut(enteringView, leavingView, opts) {
_classCallCheck(this, AlertPopOut);
_get(Object.getPrototypeOf(AlertPopOut.prototype), "constructor", this).call(this, null, opts);
var ele = leavingView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.alert-wrapper'));
wrapper.fromTo('opacity', '1', '0').fromTo('scale', '1', '0.9');
backdrop.fromTo('opacity', '0.3', '0');
this.easing('ease-in-out').duration(200).add(backdrop, wrapper);
}
return AlertPopOut;
})(Animation);
Animation.register('alert-pop-out', AlertPopOut);
AlertMdPopIn = (function (_Animation3) {
_inherits(AlertMdPopIn, _Animation3);
function AlertMdPopIn(enteringView, leavingView, opts) {
_classCallCheck(this, AlertMdPopIn);
_get(Object.getPrototypeOf(AlertMdPopIn.prototype), "constructor", this).call(this, null, opts);
var ele = enteringView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.alert-wrapper'));
wrapper.fromTo('opacity', '0.01', '1').fromTo('scale', '1.1', '1');
backdrop.fromTo('opacity', '0.01', '0.5');
this.easing('ease-in-out').duration(200).add(backdrop, wrapper);
}
return AlertMdPopIn;
})(Animation);
Animation.register('alert-md-pop-in', AlertMdPopIn);
AlertMdPopOut = (function (_Animation4) {
_inherits(AlertMdPopOut, _Animation4);
function AlertMdPopOut(enteringView, leavingView, opts) {
_classCallCheck(this, AlertMdPopOut);
_get(Object.getPrototypeOf(AlertMdPopOut.prototype), "constructor", this).call(this, null, opts);
var ele = leavingView.pageRef().nativeElement;
var backdrop = new Animation(ele.querySelector('.backdrop'));
var wrapper = new Animation(ele.querySelector('.alert-wrapper'));
wrapper.fromTo('opacity', '1', '0').fromTo('scale', '1', '0.9');
backdrop.fromTo('opacity', '0.5', '0');
this.easing('ease-in-out').duration(200).add(backdrop, wrapper);
}
return AlertMdPopOut;
})(Animation);
Animation.register('alert-md-pop-out', AlertMdPopOut);
}
};
});
System.register("ionic/components/app/app", ["angular2/core", "angular2/platform/browser", "../../config/config", "../../util/click-block", "../../util/dom"], function (_export) {
/**
* @private
* Component registry service. For more information on registering
* components see the [IdRef API reference](../id/IdRef/).
*/
"use strict";
var Injectable, NgZone, Title, Config, ClickBlock, rafFrames, __decorate, __metadata, IonicApp, _a, _b, _c;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Injectable = _angular2Core.Injectable;
NgZone = _angular2Core.NgZone;
}, function (_angular2PlatformBrowser) {
Title = _angular2PlatformBrowser.Title;
}, function (_configConfig) {
Config = _configConfig.Config;
}, function (_utilClickBlock) {
ClickBlock = _utilClickBlock.ClickBlock;
}, function (_utilDom) {
rafFrames = _utilDom.rafFrames;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
IonicApp = (function () {
function IonicApp(_config, _clickBlock, _zone) {
_classCallCheck(this, IonicApp);
this._config = _config;
this._clickBlock = _clickBlock;
this._zone = _zone;
this._titleSrv = new Title();
this._title = '';
this._disTime = 0;
this._scrollTime = 0;
// Our component registry map
this.components = {};
}
/**
* Sets the document title.
* @param {string} val Value to set the document title to.
*/
_createClass(IonicApp, [{
key: "setTitle",
value: function setTitle(val) {
var self = this;
if (val !== self._title) {
self._title = val;
this._zone.runOutsideAngular(function () {
function setAppTitle() {
self._titleSrv.setTitle(self._title);
}
rafFrames(4, setAppTitle);
});
}
}
/**
* @private
* Sets if the app is currently enabled or not, meaning if it's
* available to accept new user commands. For example, this is set to `false`
* while views transition, a modal slides up, an action-sheet
* slides up, etc. After the transition completes it is set back to `true`.
* @param {bool} isEnabled
* @param {bool} fallback When `isEnabled` is set to `false`, this argument
* is used to set the maximum number of milliseconds that app will wait until
* it will automatically enable the app again. It's basically a fallback incase
* something goes wrong during a transition and the app wasn't re-enabled correctly.
*/
}, {
key: "setEnabled",
value: function setEnabled(isEnabled) {
var duration = arguments.length <= 1 || arguments[1] === undefined ? 700 : arguments[1];
this._disTime = isEnabled ? 0 : Date.now() + duration;
if (duration > 32 || isEnabled) {
// only do a click block if the duration is longer than XXms
this._clickBlock.show(!isEnabled, duration + 64);
}
}
/**
* @private
* Boolean if the app is actively enabled or not.
* @return {bool}
*/
}, {
key: "isEnabled",
value: function isEnabled() {
return this._disTime < Date.now();
}
/**
* @private
*/
}, {
key: "setScrolling",
value: function setScrolling() {
this._scrollTime = Date.now();
}
/**
* @private
* Boolean if the app is actively scrolling or not.
* @return {bool}
*/
}, {
key: "isScrolling",
value: function isScrolling() {
return this._scrollTime + 64 > Date.now();
}
/**
* @private
* Register a known component with a key, for easy lookups later.
* @param {TODO} id The id to use to register the component
* @param {TODO} component The component to register
*/
}, {
key: "register",
value: function register(id, component) {
if (this.components[id] && this.components[id] !== component) {}
this.components[id] = component;
}
/**
* @private
* Unregister a known component with a key.
* @param {TODO} id The id to use to unregister
*/
}, {
key: "unregister",
value: function unregister(id) {
delete this.components[id];
}
/**
* @private
* Get a registered component with the given type (returns the first)
* @param {Object} cls the type to search for
* @return the matching component, or undefined if none was found
*/
}, {
key: "getRegisteredComponent",
value: function getRegisteredComponent(cls) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.components[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var component = _step.value;
if (component instanceof cls) {
return component;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"]) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
/**
* @private
* Get the component for the given key.
* @param {TODO} key TODO
* @return {TODO} TODO
*/
}, {
key: "getComponent",
value: function getComponent(id) {
return this.components[id];
}
}]);
return IonicApp;
})();
_export("IonicApp", IonicApp);
_export("IonicApp", IonicApp = __decorate([Injectable(), __metadata('design:paramtypes', [typeof (_a = typeof Config !== 'undefined' && Config) === 'function' && _a || Object, typeof (_b = typeof ClickBlock !== 'undefined' && ClickBlock) === 'function' && _b || Object, typeof (_c = typeof NgZone !== 'undefined' && NgZone) === 'function' && _c || Object])], IonicApp));
}
};
});
System.register("ionic/components/app/id", ["angular2/core", "./app"], function (_export) {
/**
* @name Id
* @description
* IdRef is an easy way to identify unique components in an app and access them
* no matter where in the UI heirarchy you are. For example, this makes toggling
* a global side menu feasible from any place in the application.
*
* See the [Menu section](https://ionicframework.com/docs/v3/components/#menus) of
* the Component docs for an example of how Menus rely on ID's.
*
* @usage
* To give any component an ID, simply set its `id` property:
* ```html
*
* ```
*
* To get a reference to the registered component, inject the [IonicApp](../app/IonicApp/)
* service:
* ```ts
* constructor(app: IonicApp) {
* this.app = app
* }
* ngAfterViewInit{
* var checkbox = this.app.getComponent("myCheckbox");
* if (checkbox.checked) {
* console.log('checkbox is checked');
* }
* }
* ```
*
* *NOTE:* It is not recommended to use ID's across Pages, as there is often no
* guarantee that the registered component has not been destroyed if its Page
* has been navigated away from.
*/
"use strict";
var AppViewManager, ElementRef, Directive, Renderer, IonicApp, __decorate, __metadata, IdRef, Attr, _a, _b, _c, _d, _e;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
AppViewManager = _angular2Core.AppViewManager;
ElementRef = _angular2Core.ElementRef;
Directive = _angular2Core.Directive;
Renderer = _angular2Core.Renderer;
}, function (_app2) {
IonicApp = _app2.IonicApp;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
IdRef = (function () {
function IdRef(_app, _elementRef, _appViewManager) {
_classCallCheck(this, IdRef);
this._app = _app;
this._elementRef = _elementRef;
this._appViewManager = _appViewManager;
// Grab the component this directive is attached to
this.component = _appViewManager.getComponent(_elementRef);
}
/**
* @private
*/
_createClass(IdRef, [{
key: "ngOnInit",
value: function ngOnInit() {
this._app.register(this.id, this.component);
}
/**
* @private
*/
}, {
key: "ngOnDestroy",
value: function ngOnDestroy() {
this._app.unregister(this.id);
}
}]);
return IdRef;
})();
_export("IdRef", IdRef);
_export("IdRef", IdRef = __decorate([Directive({
selector: '[id]',
inputs: ['id']
}), __metadata('design:paramtypes', [typeof (_a = typeof IonicApp !== 'undefined' && IonicApp) === 'function' && _a || Object, typeof (_b = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _b || Object, typeof (_c = typeof AppViewManager !== 'undefined' && AppViewManager) === 'function' && _c || Object])], IdRef));
/**
* @name Attr
* @description
* Attr allows you to dynamically add or remove an attribute based on the value of an expression or variable.
* @usage
* ```html
* // toggle the no-lines attributes based on whether isAndroid is true or false
*
* ```
* @demo /docs/v3/demos/attr/
*/
Attr = (function () {
function Attr(_renderer, _elementRef) {
_classCallCheck(this, Attr);
this._renderer = _renderer;
this._elementRef = _elementRef;
}
/**
* @private
*/
_createClass(Attr, [{
key: "ngOnInit",
value: function ngOnInit() {
this._renderer.setElementAttribute(this._elementRef, this.attr, '');
}
}]);
return Attr;
})();
_export("Attr", Attr);
_export("Attr", Attr = __decorate([Directive({
selector: '[attr]',
inputs: ['attr']
}), __metadata('design:paramtypes', [typeof (_d = typeof Renderer !== 'undefined' && Renderer) === 'function' && _d || Object, typeof (_e = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _e || Object])], Attr));
}
};
});
System.register("ionic/components/blur/blur", ["angular2/core"], function (_export) {
/**
* @name Blur
* @description
* The blur attribute applies the CSS blur attribute to an element. If the CSS attribute is not supported,
* it will fall back to applying a semi-transparent background color to the element.
*
* @usage
* ```html
*
* This card will blur the content behind it.
*
* ```
*
* @demo /docs/v3/demos/blur/
*/
"use strict";
var Directive, Renderer, ElementRef, __decorate, __metadata, Blur, _a, _b;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Directive = _angular2Core.Directive;
Renderer = _angular2Core.Renderer;
ElementRef = _angular2Core.ElementRef;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Blur = function Blur(_elementRef, _renderer) {
_classCallCheck(this, Blur);
this._elementRef = _elementRef;
this._renderer = _renderer;
_renderer.setElementStyle(_elementRef, '-webkit-backdrop-filter', 'blur(10px)');
};
_export("Blur", Blur);
_export("Blur", Blur = __decorate([Directive({
selector: '[blur]'
}), __metadata('design:paramtypes', [typeof (_a = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _a || Object, typeof (_b = typeof Renderer !== 'undefined' && Renderer) === 'function' && _b || Object])], Blur));
}
};
});
System.register("ionic/components/button/button", ["angular2/core", "../../config/config"], function (_export) {
/**
* @name Button
* @module ionic
* @property [outline] - for an unfilled outline button
* @property [clear] - for a transparent button that only shows text and icons
* @property [round] - for a button with rounded corners
* @property [block] - for a block button that fills it's parent container
* @property [full] - for a full width button
* @property [small] - sets button size to small
* @property [large] - sets button size to large
* @property [disabled] - disables the button
* @property [fab] - for a floating action button
* @property [fab-left] - position a fab button to the left
* @property [fab-right] - position a fab button to the right
* @property [fab-center] - position a fab button towards the center
* @property [fab-top] - position a fab button towards the top
* @property [fab-bottom] - position a fab button towards the bottom
* @property [color] - Dynamically set which color attribute this button should use.
* @description
* Buttons are simple components in Ionic, can consist of text, an icon, or both, and can be enhanced with a wide range of attributes.
* @demo /docs/v3/demos/buttons/
* @see {@link /docs/v3/components#buttons Button Component Docs}
*/
"use strict";
var Directive, ElementRef, Renderer, Attribute, Config, __decorate, __metadata, __param, Button, BUTTON_SIZE_ATTRS, BUTTON_STYLE_ATTRS, BUTTON_SHAPE_ATTRS, BUTTON_DISPLAY_ATTRS, IGNORE_ATTRS, TEXT, ICON, _a, _b, _c;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Directive = _angular2Core.Directive;
ElementRef = _angular2Core.ElementRef;
Renderer = _angular2Core.Renderer;
Attribute = _angular2Core.Attribute;
}, function (_configConfig) {
Config = _configConfig.Config;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
__param = undefined && undefined.__param || function (paramIndex, decorator) {
return function (target, key) {
decorator(target, key, paramIndex);
};
};
Button = (function () {
function Button(config, _elementRef, _renderer, ionItem) {
_classCallCheck(this, Button);
this._elementRef = _elementRef;
this._renderer = _renderer;
this._role = 'button'; // bar-button/item-button
this._size = null; // large/small
this._style = 'default'; // outline/clear/solid
this._shape = null; // round/fab
this._display = null; // block/full
this._lastColor = null;
this._colors = []; // primary/secondary
this._icon = null; // left/right/only
this._disabled = false; // disabled
this.isItem = ionItem === '';
var element = _elementRef.nativeElement;
if (config.get('hoverCSS') === false) {
_renderer.setElementClass(_elementRef, 'disable-hover', true);
}
if (element.hasAttribute('ion-item')) {
// no need to put on these classes for an ion-item
this._role = null;
return;
}
if (element.hasAttribute('disabled')) {
this._disabled = true;
}
this._readAttrs(element);
this._readIcon(element);
}
/**
* @private
*/
_createClass(Button, [{
key: "ngAfterContentInit",
value: function ngAfterContentInit() {
this._lastColor = this.color;
if (this.color) {
this._colors = [this.color];
}
this._assignCss(true);
}
/**
* @private
*/
}, {
key: "ngAfterContentChecked",
value: function ngAfterContentChecked() {
if (this._lastColor !== this.color) {
this._assignCss(false);
this._lastColor = this.color;
this._colors = [this.color];
this._assignCss(true);
}
}
/**
* @private
*/
}, {
key: "addClass",
value: function addClass(className) {
this._renderer.setElementClass(this._elementRef, className, true);
}
/**
* @private
*/
}, {
key: "setRole",
value: function setRole(val) {
this._role = val;
}
}, {
key: "_readIcon",
value: function _readIcon(element) {
// figure out if and where the icon lives in the button
var childNodes = element.childNodes;
var childNode = undefined;
var nodes = [];
for (var i = 0, l = childNodes.length; i < l; i++) {
childNode = childNodes[i];
if (childNode.nodeType === 3) {
// text node
if (childNode.textContent.trim() !== '') {
nodes.push(TEXT);
}
} else if (childNode.nodeType === 1) {
if (childNode.nodeName === 'ION-ICON') {
// icon element node
nodes.push(ICON);
} else {
// element other than an
nodes.push(TEXT);
}
}
}
if (nodes.length > 1) {
if (nodes[0] === ICON && nodes[1] === TEXT) {
this._icon = 'icon-left';
} else if (nodes[0] === TEXT && nodes[1] === ICON) {
this._icon = 'icon-right';
}
} else if (nodes.length === 1 && nodes[0] === ICON) {
this._icon = 'icon-only';
}
}
}, {
key: "_readAttrs",
value: function _readAttrs(element) {
var elementAttrs = element.attributes;
var attrName = undefined;
for (var i = 0, l = elementAttrs.length; i < l; i++) {
if (elementAttrs[i].value !== '') continue;
attrName = elementAttrs[i].name;
if (BUTTON_STYLE_ATTRS.indexOf(attrName) > -1) {
this._style = attrName;
} else if (BUTTON_DISPLAY_ATTRS.indexOf(attrName) > -1) {
this._display = attrName;
} else if (BUTTON_SHAPE_ATTRS.indexOf(attrName) > -1) {
this._shape = attrName;
} else if (BUTTON_SIZE_ATTRS.indexOf(attrName) > -1) {
this._size = attrName;
} else if (!IGNORE_ATTRS.test(attrName)) {
this._colors.push(attrName);
}
}
}
}, {
key: "_assignCss",
value: function _assignCss(assignCssClass) {
var _this = this;
var role = this._role;
if (role) {
(function () {
_this._renderer.setElementClass(_this._elementRef, role, assignCssClass); // button
_this._setClass(_this._style, assignCssClass); // button-clear
_this._setClass(_this._shape, assignCssClass); // button-round
_this._setClass(_this._display, assignCssClass); // button-full
_this._setClass(_this._size, assignCssClass); // button-small
_this._setClass(_this._icon, assignCssClass); // button-icon-left
var colorStyle = _this._style !== 'default' ? _this._style + '-' : '';
_this._colors.forEach(function (colorName) {
_this._setClass(colorStyle + colorName, assignCssClass); // button-secondary, button-clear-secondary
});
})();
}
}
}, {
key: "_setClass",
value: function _setClass(type, assignCssClass) {
if (type) {
this._renderer.setElementClass(this._elementRef, this._role + '-' + type, assignCssClass);
}
}
/**
* @private
*/
}], [{
key: "setRoles",
value: function setRoles(contentButtonChildren, role) {
var buttons = contentButtonChildren.toArray();
buttons.forEach(function (button) {
button.setRole(role);
});
}
}]);
return Button;
})();
_export("Button", Button);
_export("Button", Button = __decorate([Directive({
selector: 'button,[button]',
inputs: ['color']
}), __param(3, Attribute('ion-item')), __metadata('design:paramtypes', [typeof (_a = typeof Config !== 'undefined' && Config) === 'function' && _a || Object, typeof (_b = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _b || Object, typeof (_c = typeof Renderer !== 'undefined' && Renderer) === 'function' && _c || Object, String])], Button));
BUTTON_SIZE_ATTRS = ['large', 'small'];
BUTTON_STYLE_ATTRS = ['clear', 'outline', 'solid'];
BUTTON_SHAPE_ATTRS = ['round', 'fab'];
BUTTON_DISPLAY_ATTRS = ['block', 'full'];
IGNORE_ATTRS = /_ng|button|left|right/;
TEXT = 1;
ICON = 2;
}
};
});
System.register("ionic/components/checkbox/checkbox", ["angular2/core", "angular2/common", "../../util/form"], function (_export) {
/**
* The checkbox is no different than the HTML checkbox input, except it's styled differently.
*
* See the [Angular 2 Docs](https://angular.io/docs/js/latest/api/core/Form-interface.html) for more info on forms and input.
*
* @property [checked] - whether or not the checkbox is checked (defaults to false)
* @property [value] - the value of the checkbox component
* @property [disabled] - whether or not the checkbox is disabled or not.
*
* @usage
* ```html
*
* HTML5
*
* ```
* @demo /docs/v3/demos/checkbox/
* @see {@link /docs/v3/components#checkbox Checkbox Component Docs}
*/
"use strict";
var Component, Optional, ElementRef, Input, Renderer, HostListener, NgControl, Form, __decorate, __metadata, __param, Checkbox, _a, _b, _c, _d;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Component = _angular2Core.Component;
Optional = _angular2Core.Optional;
ElementRef = _angular2Core.ElementRef;
Input = _angular2Core.Input;
Renderer = _angular2Core.Renderer;
HostListener = _angular2Core.HostListener;
}, function (_angular2Common) {
NgControl = _angular2Common.NgControl;
}, function (_utilForm) {
Form = _utilForm.Form;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
__param = undefined && undefined.__param || function (paramIndex, decorator) {
return function (target, key) {
decorator(target, key, paramIndex);
};
};
Checkbox = (function () {
function Checkbox(_form, _elementRef, _renderer, ngControl) {
_classCallCheck(this, Checkbox);
this._form = _form;
this._elementRef = _elementRef;
this._renderer = _renderer;
this.value = '';
this.checked = false;
this.disabled = false;
_form.register(this);
if (ngControl) {
ngControl.valueAccessor = this;
}
}
/**
* @private
*/
_createClass(Checkbox, [{
key: "ngOnInit",
value: function ngOnInit() {
if (!this.id) {
this.id = 'chk-' + this._form.nextId();
this._renderer.setElementAttribute(this._elementRef, 'id', this.id);
}
this.labelId = 'lbl-' + this.id;
this._renderer.setElementAttribute(this._elementRef, 'aria-labelledby', this.labelId);
}
/**
* @private
* Toggle the checked state of the checkbox. Calls onChange to pass the updated checked state to the model (Control).
*/
}, {
key: "toggle",
value: function toggle() {
this.checked = !this.checked;
}
}, {
key: "_click",
/**
* @private
*/
value: function _click(ev) {
ev.preventDefault();
ev.stopPropagation();
this.toggle();
}
/**
* @private
* Angular2 Forms API method called by the model (Control) on change to update
* the checked value.
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L34
*/
}, {
key: "writeValue",
value: function writeValue(value) {
this.checked = value;
}
/**
* @private
*/
}, {
key: "onChange",
value: function onChange(val) {}
// TODO: figure the whys and the becauses
/**
* @private
*/
}, {
key: "onTouched",
value: function onTouched(val) {}
// TODO: figure the whys and the becauses
/**
* @private
* Angular2 Forms API method called by the view (NgControl) to register the
* onChange event handler that updates the model (Control).
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L27
* @param {Function} fn the onChange event handler.
*/
}, {
key: "registerOnChange",
value: function registerOnChange(fn) {
this.onChange = fn;
}
/**
* @private
* Angular2 Forms API method called by the the view (NgControl) to register
* the onTouched event handler that marks model (Control) as touched.
* @param {Function} fn onTouched event handler.
*/
}, {
key: "registerOnTouched",
value: function registerOnTouched(fn) {
this.onTouched = fn;
}
/**
* @private
*/
}, {
key: "ngOnDestroy",
value: function ngOnDestroy() {
this._form.deregister(this);
}
}, {
key: "checked",
get: function get() {
return !!this._checked;
},
set: function set(val) {
this._checked = !!val;
this._renderer.setElementAttribute(this._elementRef, 'aria-checked', this._checked);
this.onChange(this._checked);
}
}]);
return Checkbox;
})();
_export("Checkbox", Checkbox);
__decorate([Input(), __metadata('design:type', String)], Checkbox.prototype, "value", void 0);
__decorate([Input(), __metadata('design:type', Object)], Checkbox.prototype, "checked", void 0);
__decorate([Input(), __metadata('design:type', Boolean)], Checkbox.prototype, "disabled", void 0);
__decorate([Input(), __metadata('design:type', String)], Checkbox.prototype, "id", void 0);
__decorate([HostListener('click', ['$event']), __metadata('design:type', Function), __metadata('design:paramtypes', [Object]), __metadata('design:returntype', void 0)], Checkbox.prototype, "_click", null);
_export("Checkbox", Checkbox = __decorate([Component({
selector: 'ion-checkbox',
host: {
'role': 'checkbox',
'class': 'item',
'tappable': '',
'tabindex': 0,
'[attr.aria-disabled]': 'disabled'
},
template: '
' + '
' + '' + '
' + '' + '' + '' + '
'
}), __param(3, Optional()), __metadata('design:paramtypes', [typeof (_a = typeof Form !== 'undefined' && Form) === 'function' && _a || Object, typeof (_b = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _b || Object, typeof (_c = typeof Renderer !== 'undefined' && Renderer) === 'function' && _c || Object, typeof (_d = typeof NgControl !== 'undefined' && NgControl) === 'function' && _d || Object])], Checkbox));
}
};
});
System.register("ionic/components/content/content", ["angular2/core", "../ion", "../app/app", "../../config/config", "../../util/dom", "../nav/view-controller", "../../animations/scroll-to"], function (_export) {
/**
* @name Content
* @description
* The Content component provides an easy to use content area that can be configured to use Ionic's custom Scroll View, or the built in overflow scrolling of the browser.
*
* While we recommend using the custom Scroll features in Ionic in most cases, sometimes (for performance reasons) only the browser's native overflow scrolling will suffice, and so we've made it easy to toggle between the Ionic scroll implementation and overflow scrolling.
*
* You can implement pull-to-refresh with the [Refresher](../../scroll/Refresher) component.
*
* @usage
* ```html
*
* Add your content here!
*
* ```
*
*/
"use strict";
var Component, ElementRef, Optional, NgZone, Ion, IonicApp, Config, raf, ViewController, ScrollTo, __decorate, __metadata, __param, Content, _a, _b, _c, _d, _e;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
return {
setters: [function (_angular2Core) {
Component = _angular2Core.Component;
ElementRef = _angular2Core.ElementRef;
Optional = _angular2Core.Optional;
NgZone = _angular2Core.NgZone;
}, function (_ion) {
Ion = _ion.Ion;
}, function (_appApp) {
IonicApp = _appApp.IonicApp;
}, function (_configConfig) {
Config = _configConfig.Config;
}, function (_utilDom) {
raf = _utilDom.raf;
}, function (_navViewController) {
ViewController = _navViewController.ViewController;
}, function (_animationsScrollTo) {
ScrollTo = _animationsScrollTo.ScrollTo;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
__param = undefined && undefined.__param || function (paramIndex, decorator) {
return function (target, key) {
decorator(target, key, paramIndex);
};
};
Content = (function (_Ion) {
_inherits(Content, _Ion);
/**
* @param {ElementRef} elementRef A reference to the component's DOM element.
* @param {Config} config The config object to change content's default settings.
*/
function Content(elementRef, _config, viewCtrl, _app, _zone) {
_classCallCheck(this, Content);
_get(Object.getPrototypeOf(Content.prototype), "constructor", this).call(this, elementRef, _config);
this._config = _config;
this._app = _app;
this._zone = _zone;
this.scrollPadding = 0;
if (viewCtrl) {
viewCtrl.setContent(this);
viewCtrl.setContentRef(elementRef);
}
}
/**
* @private
*/
_createClass(Content, [{
key: "ngOnInit",
value: function ngOnInit() {
_get(Object.getPrototypeOf(Content.prototype), "ngOnInit", this).call(this);
var self = this;
self.scrollElement = self.getNativeElement().children[0];
self._scroll = function (ev) {
self._app.setScrolling();
};
if (self._config.get('tapPolyfill') === true) {
self._zone.runOutsideAngular(function () {
self.scrollElement.addEventListener('scroll', self._scroll);
});
}
}
}, {
key: "ngOnDestroy",
value: function ngOnDestroy() {
this.scrollElement.removeEventListener('scroll', this._scroll);
}
/**
* Adds the specified scroll handler to the content' scroll element.
*
* ```ts
* @Page({
* template: ``
* )}
* export class MyPage{
* constructor(app: IonicApp){
* this.app = app;
* }
* // Need to wait until the component has been initialized
* ngAfterViewInit() {
* // Here 'my-content' is the ID of my ion-content
* this.content = this.app.getComponent('my-content');
* this.content.addScrollEventListener(this.myScroll);
* }
* myScroll() {
* console.info('They see me scrolling...');
* }
* }
* ```
* @param {Function} handler The method you want perform when scrolling
* @returns {Function} A function that removes the scroll handler.
*/
}, {
key: "addScrollEventListener",
value: function addScrollEventListener(handler) {
var _this = this;
if (!this.scrollElement) {
return;
}
// ensure we're not creating duplicates
this.scrollElement.removeEventListener('scroll', handler);
this.scrollElement.addEventListener('scroll', handler);
return function () {
_this.scrollElement.removeEventListener('scroll', handler);
};
}
}, {
key: "onScrollEnd",
value: function onScrollEnd(callback) {
var lastScrollTop = null;
var framesUnchanged = 0;
var scrollElement = this.scrollElement;
function next() {
var currentScrollTop = scrollElement.scrollTop;
if (lastScrollTop !== null) {
if (Math.round(lastScrollTop) === Math.round(currentScrollTop)) {
framesUnchanged++;
} else {
framesUnchanged = 0;
}
if (framesUnchanged > 9) {
return callback();
}
}
lastScrollTop = currentScrollTop;
raf(function () {
raf(next);
});
}
setTimeout(next, 100);
}
/**
* Adds the specified touchmove handler to the content's scroll element.
*
* ```ts
* @Page({
* template: ``
* )}
* export class MyPage{
* constructor(app: IonicApp){
* this.app = app;
* }
* // Need to wait until the component has been initialized
* ngAfterViewInit() {
* // Here 'my-content' is the ID of my ion-content
* this.content = this.app.getComponent('my-content');
* this.content.addTouchMoveListener(this.touchHandler);
* }
* touchHandler() {
* console.log("I'm touching all the magazines!!");
* }
* }
* ```
* @param {Function} handler The method you want to perform when touchmove is firing
* @returns {Function} A function that removes the touchmove handler.
*/
}, {
key: "addTouchMoveListener",
value: function addTouchMoveListener(handler) {
var _this2 = this;
if (!this.scrollElement) {
return;
}
// ensure we're not creating duplicates
this.scrollElement.removeEventListener('touchmove', handler);
this.scrollElement.addEventListener('touchmove', handler);
return function () {
_this2.scrollElement.removeEventListener('touchmove', handler);
};
}
/**
* Scroll to the specified position.
*
* ```ts
* @Page({
* template: `
*
* `
* )}
* export class MyPage{
* constructor(app: IonicApp){
* this.app = app;
* }
* // Need to wait until the component has been initialized
* ngAfterViewInit() {
* // Here 'my-content' is the ID of my ion-content
* this.content = this.app.getComponent('my-content');
* }
* scrollTo() {
* this.content.scrollTo(0, 500, 200);
* }
* }
* ```
* @param {Number} x The x-value to scroll to.
* @param {Number} y The y-value to scroll to.
* @param {Number} duration Duration of the scroll animation in ms.
* @param {TODO} tolerance TODO
* @returns {Promise} Returns a promise when done
*/
}, {
key: "scrollTo",
value: function scrollTo(x, y, duration, tolerance) {
if (this._scrollTo) {
this._scrollTo.dispose();
}
this._scrollTo = new ScrollTo(this.scrollElement);
return this._scrollTo.start(x, y, duration, tolerance);
}
/**
* Scroll to the specified position.
*
* ```ts
* @Page({
* template: `
*
* `
* )}
* export class MyPage{
* constructor(app: IonicApp){
* this.app = app;
* }
* // Need to wait until the component has been initialized
* ngAfterViewInit() {
* // Here 'my-content' is the ID of my ion-content
* this.content = this.app.getComponent('my-content');
* }
* scrollTop() {
* this.content.scrollTop();
* }
* }
* ```
* @returns {Promise} Returns a promise when done
*/
}, {
key: "scrollToTop",
value: function scrollToTop() {
if (this._scrollTo) {
this._scrollTo.dispose();
}
this._scrollTo = new ScrollTo(this.scrollElement);
return this._scrollTo.start(0, 0, 300, 0);
}
/**
* @private
* Returns the content and scroll elements' dimensions.
* @returns {Object} dimensions The content and scroll elements' dimensions
* {Number} dimensions.contentHeight content offsetHeight
* {Number} dimensions.contentTop content offsetTop
* {Number} dimensions.contentBottom content offsetTop+offsetHeight
* {Number} dimensions.contentWidth content offsetWidth
* {Number} dimensions.contentLeft content offsetLeft
* {Number} dimensions.contentRight content offsetLeft + offsetWidth
* {Number} dimensions.scrollHeight scroll scrollHeight
* {Number} dimensions.scrollTop scroll scrollTop
* {Number} dimensions.scrollBottom scroll scrollTop + scrollHeight
* {Number} dimensions.scrollWidth scroll scrollWidth
* {Number} dimensions.scrollLeft scroll scrollLeft
* {Number} dimensions.scrollRight scroll scrollLeft + scrollWidth
*/
}, {
key: "getDimensions",
value: function getDimensions() {
var scrollElement = this.scrollElement;
var parentElement = scrollElement.parentElement;
return {
contentHeight: parentElement.offsetHeight,
contentTop: parentElement.offsetTop,
contentBottom: parentElement.offsetTop + parentElement.offsetHeight,
contentWidth: parentElement.offsetWidth,
contentLeft: parentElement.offsetLeft,
contentRight: parentElement.offsetLeft + parentElement.offsetWidth,
scrollHeight: scrollElement.scrollHeight,
scrollTop: scrollElement.scrollTop,
scrollBottom: scrollElement.scrollTop + scrollElement.scrollHeight,
scrollWidth: scrollElement.scrollWidth,
scrollLeft: scrollElement.scrollLeft,
scrollRight: scrollElement.scrollLeft + scrollElement.scrollWidth
};
}
/**
* @private
* Adds padding to the bottom of the scroll element when the keyboard is open
* so content below the keyboard can be scrolled into view.
*/
}, {
key: "addScrollPadding",
value: function addScrollPadding(newScrollPadding) {
if (newScrollPadding > this.scrollPadding) {
console.debug('addScrollPadding', newScrollPadding);
this.scrollPadding = newScrollPadding;
this.scrollElement.style.paddingBottom = newScrollPadding + 'px';
}
}
}]);
return Content;
})(Ion);
_export("Content", Content);
_export("Content", Content = __decorate([Component({
selector: 'ion-content',
template: '' + '' + ''
}), __param(2, Optional()), __metadata('design:paramtypes', [typeof (_a = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _a || Object, typeof (_b = typeof Config !== 'undefined' && Config) === 'function' && _b || Object, typeof (_c = typeof ViewController !== 'undefined' && ViewController) === 'function' && _c || Object, typeof (_d = typeof IonicApp !== 'undefined' && IonicApp) === 'function' && _d || Object, typeof (_e = typeof NgZone !== 'undefined' && NgZone) === 'function' && _e || Object])], Content));
}
};
});
System.register("ionic/components/icon/icon", ["angular2/core", "../../config/config"], function (_export) {
/**
* @name Icon
* @description
* Icons can be used on their own, or inside of a number of Ionic components.
* For a full list of available icons, check out the
* [Ionicons resource docs](../../../../resources/ionicons).
*
* One feature of Ionicons is that when icon names are set, the actual icon
* which is rendered can change slightly depending on the mode the app is
* running from. For example, by setting the icon name of `alarm`, on iOS the
* icon will automatically apply `ios-alarm`, and on Material Design it will
* automatically apply `md-alarm`. This allow the developer to write the
* markup once, and let Ionic automatically apply the appropriate icon.
*
* @usage
* ```html
*
*
*
*
*
*
*
*
*
* ```
*
* @property {string} [name] - Use the appropriate icon for the mode.
* @property {string} [ios] - Explicitly set the icon to use on iOS.
* @property {string} [md] - Explicitly set the icon to use on Android.
* @property {boolean} [isActive] - Whether or not the icon has an "active"
* appearance. On iOS an active icon is filled in or full appearance, and an
* inactive icon on iOS will use an outlined version of the icon same icon.
* Material Design icons do not change appearance depending if they're active
* or not. The `isActive` property is largely used by the tabbar.
* @see {@link /docs/v3/components#icons Icon Component Docs}
*
*/
"use strict";
var Directive, ElementRef, Renderer, Config, __decorate, __metadata, Icon, _a, _b, _c;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Directive = _angular2Core.Directive;
ElementRef = _angular2Core.ElementRef;
Renderer = _angular2Core.Renderer;
}, function (_configConfig) {
Config = _configConfig.Config;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Icon = (function () {
function Icon(config, _elementRef, _renderer) {
_classCallCheck(this, Icon);
this._elementRef = _elementRef;
this._renderer = _renderer;
this.mode = config.get('iconMode');
this._name = '';
this._ios = '';
this._md = '';
this._css = '';
if (_elementRef.nativeElement.tagName === 'ICON') {
// deprecated warning
console.warn(' has been renamed to ');
console.warn(' requires the "name" attribute w/ a value');
console.warn(' should now be ');
}
}
_createClass(Icon, [{
key: "update",
/**
* @private
*/
value: function update() {
var css = 'ion-';
if (this._ios && this.mode === 'ios') {
css += this._ios;
} else if (this._md && this.mode === 'md') {
css += this._md;
} else {
css += this._name;
}
if (this.mode == 'ios' && !this.isActive) {
css += '-outline';
}
if (this._css !== css) {
if (this._css) {
this._renderer.setElementClass(this._elementRef, this._css, false);
}
this._css = css;
this._renderer.setElementClass(this._elementRef, css, true);
this._renderer.setElementAttribute(this._elementRef, 'aria-label', css.replace('ion-', '').replace('ios-', '').replace('md-', '').replace('-', ' '));
}
}
/**
* @private
*/
}, {
key: "addClass",
value: function addClass(className) {
this._renderer.setElementClass(this._elementRef, className, true);
}
}, {
key: "name",
get: function get() {
return this._name;
},
/**
* @private
*/
set: function set(val) {
if (!/^md-|^ios-|-logo$/.test(val)) {
// this does not have one of the defaults
// so lets auto add in the mode prefix for them
val = this.mode + '-' + val;
}
this._name = val;
this.update();
}
}, {
key: "ios",
get: function get() {
return this._ios;
},
/**
* @private
*/
set: function set(val) {
this._ios = val;
this.update();
}
}, {
key: "md",
get: function get() {
return this._md;
},
/**
* @private
*/
set: function set(val) {
this._md = val;
this.update();
}
}, {
key: "isActive",
get: function get() {
return this._isActive === undefined || this._isActive === true || this._isActive === 'true';
},
/**
* @private
*/
set: function set(val) {
this._isActive = val;
this.update();
}
}]);
return Icon;
})();
_export("Icon", Icon);
_export("Icon", Icon = __decorate([Directive({
selector: 'ion-icon,icon',
inputs: ['name', 'ios', 'md', 'isActive'],
host: {
'role': 'img'
}
}), __metadata('design:paramtypes', [typeof (_a = typeof Config !== 'undefined' && Config) === 'function' && _a || Object, typeof (_b = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _b || Object, typeof (_c = typeof Renderer !== 'undefined' && Renderer) === 'function' && _c || Object])], Icon));
}
};
});
System.register('ionic/components/item/item-sliding-gesture', ['../../gestures/hammer', '../../gestures/drag-gesture', '../../util/dom'], function (_export) {
'use strict';
var Hammer, DragGesture, CSS, raf, closest, ItemSlidingGesture, DRAG_THRESHOLD;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function isItemActive(ele, isActive) {
ele.classList[isActive ? 'add' : 'remove']('active-slide');
ele.classList[isActive ? 'add' : 'remove']('active-options');
}
function preventDefault(ev) {
console.debug('sliding item preventDefault', ev.type);
ev.preventDefault();
}
function getItemConatiner(ele) {
return closest(ele, 'ion-item-sliding', true);
}
function isFromOptionButtons(ele) {
return !!closest(ele, 'ion-item-options', true);
}
function getOptionsWidth(itemContainerEle) {
var optsEle = itemContainerEle.querySelector('ion-item-options');
if (optsEle) {
return optsEle.offsetWidth;
}
}
function isActive(itemContainerEle) {
return itemContainerEle.classList.contains('active-slide');
}
return {
setters: [function (_gesturesHammer) {
Hammer = _gesturesHammer.Hammer;
}, function (_gesturesDragGesture) {
DragGesture = _gesturesDragGesture.DragGesture;
}, function (_utilDom) {
CSS = _utilDom.CSS;
raf = _utilDom.raf;
closest = _utilDom.closest;
}],
execute: function () {
ItemSlidingGesture = (function (_DragGesture) {
_inherits(ItemSlidingGesture, _DragGesture);
function ItemSlidingGesture(list, listEle) {
var _this = this;
_classCallCheck(this, ItemSlidingGesture);
_get(Object.getPrototypeOf(ItemSlidingGesture.prototype), 'constructor', this).call(this, listEle, {
direction: 'x',
threshold: DRAG_THRESHOLD
});
this.data = {};
this.openItems = 0;
this.list = list;
this.listEle = listEle;
this.canDrag = true;
this.listen();
this.tap = function (ev) {
if (!isFromOptionButtons(ev.target)) {
var didClose = _this.closeOpened();
if (didClose) {
console.debug('tap close sliding item');
preventDefault(ev);
}
}
};
this.mouseOut = function (ev) {
if (ev.target.tagName === 'ION-ITEM-SLIDING') {
console.debug('tap close sliding item');
_this.onDragEnd(ev);
}
};
}
_createClass(ItemSlidingGesture, [{
key: 'onDragStart',
value: function onDragStart(ev) {
var itemContainerEle = getItemConatiner(ev.target);
if (!itemContainerEle) {
console.debug('onDragStart, no itemContainerEle');
return;
}
this.closeOpened(itemContainerEle);
var openAmout = this.getOpenAmount(itemContainerEle);
var itemData = this.get(itemContainerEle);
this.preventDrag = openAmout > 0;
if (this.preventDrag) {
this.closeOpened();
console.debug('onDragStart, preventDefault');
return preventDefault(ev);
}
itemContainerEle.classList.add('active-slide');
this.set(itemContainerEle, 'offsetX', openAmout);
this.set(itemContainerEle, 'startX', ev.center[this.direction]);
this.dragEnded = false;
}
}, {
key: 'onDrag',
value: function onDrag(ev) {
var _this2 = this;
if (this.dragEnded || this.preventDrag || Math.abs(ev.deltaY) > 30) {
console.debug('onDrag preventDrag, dragEnded:', this.dragEnded, 'preventDrag:', this.preventDrag, 'ev.deltaY:', Math.abs(ev.deltaY));
this.preventDrag = true;
return;
}
var itemContainerEle = getItemConatiner(ev.target);
if (!itemContainerEle || !isActive(itemContainerEle)) {
console.debug('onDrag, no itemContainerEle');
return;
}
var itemData = this.get(itemContainerEle);
if (!itemData.optsWidth) {
itemData.optsWidth = getOptionsWidth(itemContainerEle);
if (!itemData.optsWidth) {
console.debug('onDrag, no optsWidth');
return;
}
}
var x = ev.center[this.direction];
var delta = x - itemData.startX;
var newX = Math.max(0, itemData.offsetX - delta);
if (newX > itemData.optsWidth) {
// Calculate the new X position, capped at the top of the buttons
newX = -Math.min(-itemData.optsWidth, -itemData.optsWidth + (delta + itemData.optsWidth) * 0.4);
}
if (newX > 5 && ev.srcEvent.type.indexOf('mouse') > -1 && !itemData.hasMouseOut) {
itemContainerEle.addEventListener('mouseout', this.mouseOut);
itemData.hasMouseOut = true;
}
raf(function () {
if (!_this2.dragEnded && !_this2.preventDrag) {
isItemActive(itemContainerEle, true);
_this2.open(itemContainerEle, newX, false);
}
});
}
}, {
key: 'onDragEnd',
value: function onDragEnd(ev) {
var _this3 = this;
this.preventDrag = false;
this.dragEnded = true;
var itemContainerEle = getItemConatiner(ev.target);
if (!itemContainerEle || !isActive(itemContainerEle)) {
console.debug('onDragEnd, no itemContainerEle');
return;
}
// If we are currently dragging, we want to snap back into place
// The final resting point X will be the width of the exposed buttons
var itemData = this.get(itemContainerEle);
var restingPoint = itemData.optsWidth;
// Check if the drag didn't clear the buttons mid-point
// and we aren't moving fast enough to swipe open
if (this.getOpenAmount(itemContainerEle) < restingPoint / 2) {
// If we are going left but too slow, or going right, go back to resting
if (ev.direction & Hammer.DIRECTION_RIGHT || Math.abs(ev.velocityX) < 0.3) {
restingPoint = 0;
}
}
itemContainerEle.removeEventListener('mouseout', this.mouseOut);
itemData.hasMouseOut = false;
raf(function () {
_this3.open(itemContainerEle, restingPoint, true);
});
}
}, {
key: 'closeOpened',
value: function closeOpened(doNotCloseEle) {
var didClose = false;
if (this.openItems) {
var openItemElements = this.listEle.querySelectorAll('.active-slide');
for (var i = 0; i < openItemElements.length; i++) {
if (openItemElements[i] !== doNotCloseEle) {
this.open(openItemElements[i], 0, true);
didClose = true;
}
}
}
return didClose;
}
}, {
key: 'open',
value: function open(itemContainerEle, openAmount, isFinal) {
var _this4 = this;
var slidingEle = itemContainerEle.querySelector('ion-item,[ion-item]');
if (!slidingEle) {
console.debug('open, no slidingEle, openAmount:', openAmount);
return;
}
this.set(itemContainerEle, 'openAmount', openAmount);
clearTimeout(this.get(itemContainerEle).timerId);
if (openAmount) {
this.openItems++;
} else {
var timerId = setTimeout(function () {
if (slidingEle.style[CSS.transform] === '') {
isItemActive(itemContainerEle, false);
_this4.openItems--;
}
}, 400);
this.set(itemContainerEle, 'timerId', timerId);
}
slidingEle.style[CSS.transition] = isFinal ? '' : 'none';
slidingEle.style[CSS.transform] = openAmount ? 'translate3d(' + -openAmount + 'px,0,0)' : '';
if (isFinal) {
if (openAmount) {
isItemActive(itemContainerEle, true);
this.on('tap', this.tap);
} else {
this.off('tap', this.tap);
}
}
}
}, {
key: 'getOpenAmount',
value: function getOpenAmount(itemContainerEle) {
return this.get(itemContainerEle).openAmount || 0;
}
}, {
key: 'get',
value: function get(itemContainerEle) {
return this.data[itemContainerEle && itemContainerEle.$ionSlide] || {};
}
}, {
key: 'set',
value: function set(itemContainerEle, key, value) {
if (!this.data[itemContainerEle.$ionSlide]) {
this.data[itemContainerEle.$ionSlide] = {};
}
this.data[itemContainerEle.$ionSlide][key] = value;
}
}, {
key: 'unlisten',
value: function unlisten() {
_get(Object.getPrototypeOf(ItemSlidingGesture.prototype), 'unlisten', this).call(this);
this.listEle = null;
}
}]);
return ItemSlidingGesture;
})(DragGesture);
_export('ItemSlidingGesture', ItemSlidingGesture);
DRAG_THRESHOLD = 20;
}
};
});
System.register("ionic/components/item/item-sliding", ["angular2/core", "../list/list"], function (_export) {
/**
* @name ItemSliding
*
* @description
* Creates a list-item that can easily be swiped, deleted, reordered, edited, and more.
*
* @usage
* ```html
*
*
*
* {{item.title}}
*
*
*
*
*
*
*
* ```
* @see {@link /docs/v3/components#lists List Component Docs}
* @see {@link ../../list/List List API Docs}
*/
"use strict";
var Component, ElementRef, Optional, List, __decorate, __metadata, __param, ItemSliding, slideIds, _a, _b;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [function (_angular2Core) {
Component = _angular2Core.Component;
ElementRef = _angular2Core.ElementRef;
Optional = _angular2Core.Optional;
}, function (_listList) {
List = _listList.List;
}],
execute: function () {
__decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__metadata = undefined && undefined.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
__param = undefined && undefined.__param || function (paramIndex, decorator) {
return function (target, key) {
decorator(target, key, paramIndex);
};
};
ItemSliding = (function () {
function ItemSliding(_list, elementRef) {
_classCallCheck(this, ItemSliding);
this._list = _list;
_list.enableSlidingItems(true);
elementRef.nativeElement.$ionSlide = ++slideIds;
}
/**
* @private
*/
_createClass(ItemSliding, [{
key: "close",
value: function close() {
this._list.closeSlidingItems();
}
}]);
return ItemSliding;
})();
_export("ItemSliding", ItemSliding);
_export("ItemSliding", ItemSliding = __decorate([Component({
selector: 'ion-item-sliding',
template: '' + ''
}), __param(0, Optional()), __metadata('design:paramtypes', [typeof (_a = typeof List !== 'undefined' && List) === 'function' && _a || Object, typeof (_b = typeof ElementRef !== 'undefined' && ElementRef) === 'function' && _b || Object])], ItemSliding));
slideIds = 0;
}
};
});
System.register("ionic/components/item/item", ["angular2/core", "../button/button", "../icon/icon"], function (_export) {
/**
* @name Item
* @description
* Creates a list-item that can easily be swiped, deleted, reordered, edited, and more.
*
* There are three common ways to use an item:
* - Use `` for something that is only non-clickable text.
* - Use `