ionic-framework
Version:
The ionic-framework package comes with both Javascript and Sass frontend dependencies, located in the root of the package, and a Node API, located in `tooling/`.
1,381 lines (1,347 loc) • 854 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
__export(__webpack_require__(2));
__export(__webpack_require__(8));
__export(__webpack_require__(24));
__export(__webpack_require__(79));
__export(__webpack_require__(80));
__export(__webpack_require__(81));
__export(__webpack_require__(9));
__export(__webpack_require__(85));
__export(__webpack_require__(12));
__export(__webpack_require__(16));
__export(__webpack_require__(14));
__export(__webpack_require__(23));
__export(__webpack_require__(18));
__export(__webpack_require__(89));
// these modules don't export anything
__webpack_require__(90);
__webpack_require__(91);
__webpack_require__(92);
__webpack_require__(93);
__webpack_require__(94);
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
var core_1 = __webpack_require__(3);
var router_1 = __webpack_require__(4);
var http_1 = __webpack_require__(5);
var app_1 = __webpack_require__(6);
var config_1 = __webpack_require__(8);
var platform_1 = __webpack_require__(9);
var form_1 = __webpack_require__(13);
var keyboard_1 = __webpack_require__(14);
var scroll_to_1 = __webpack_require__(15);
var events_1 = __webpack_require__(16);
var nav_registry_1 = __webpack_require__(17);
var translate_1 = __webpack_require__(18);
var click_block_1 = __webpack_require__(12);
var feature_detect_1 = __webpack_require__(19);
var tap_click_1 = __webpack_require__(20);
var dom_1 = __webpack_require__(11);
/**
* @private
*/
function ionicProviders(args) {
if (args === void 0) { args = {}; }
var platform = new platform_1.Platform();
var navRegistry = new nav_registry_1.NavRegistry(args.pages);
var config = args.config;
if (!(config instanceof config_1.Config)) {
config = new config_1.Config(config);
}
platform.setUrl(window.location.href);
platform.setUserAgent(window.navigator.userAgent);
platform.setNavigatorPlatform(window.navigator.platform);
platform.load();
config.setPlatform(platform);
var clickBlock = new click_block_1.ClickBlock();
var events = new events_1.Events();
var featureDetect = new feature_detect_1.FeatureDetect();
setupDom(window, document, config, platform, clickBlock, featureDetect);
bindEvents(window, document, platform, events);
// prepare the ready promise to fire....when ready
platform.prepareReady(config);
return [
app_1.IonicApp,
core_1.provide(click_block_1.ClickBlock, { useValue: clickBlock }),
core_1.provide(config_1.Config, { useValue: config }),
core_1.provide(platform_1.Platform, { useValue: platform }),
core_1.provide(feature_detect_1.FeatureDetect, { useValue: featureDetect }),
core_1.provide(events_1.Events, { useValue: events }),
core_1.provide(nav_registry_1.NavRegistry, { useValue: navRegistry }),
tap_click_1.TapClick,
form_1.Form,
keyboard_1.Keyboard,
translate_1.Translate,
router_1.ROUTER_PROVIDERS,
core_1.provide(router_1.LocationStrategy, { useClass: router_1.HashLocationStrategy }),
http_1.HTTP_PROVIDERS,
];
}
exports.ionicProviders = ionicProviders;
function setupDom(window, document, config, platform, clickBlock, featureDetect) {
var bodyEle = document.body;
var mode = config.get('mode');
// if dynamic mode links have been added the fire up the correct one
var modeLinkAttr = mode + '-href';
var linkEle = document.head.querySelector('link[' + modeLinkAttr + ']');
if (linkEle) {
var href = linkEle.getAttribute(modeLinkAttr);
linkEle.removeAttribute(modeLinkAttr);
linkEle.href = href;
}
// set the mode class name
// ios/md
bodyEle.classList.add(mode);
// language and direction
platform.setDir(document.documentElement.dir, false);
platform.setLang(document.documentElement.lang, false);
var versions = platform.versions();
platform.platforms().forEach(function (platformName) {
// platform-ios
var platformClass = 'platform-' + platformName;
bodyEle.classList.add(platformClass);
var platformVersion = versions[platformName];
if (platformVersion) {
// platform-ios9
platformClass += platformVersion.major;
bodyEle.classList.add(platformClass);
// platform-ios9_3
bodyEle.classList.add(platformClass + '_' + platformVersion.minor);
}
});
// touch devices should not use :hover CSS pseudo
// enable :hover CSS when the "hoverCSS" setting is not false
if (config.get('hoverCSS') !== false) {
bodyEle.classList.add('enable-hover');
}
if (config.get('clickBlock')) {
clickBlock.enable();
}
// run feature detection tests
featureDetect.run(window, document);
}
/**
* Bind some global events and publish on the 'app' channel
*/
function bindEvents(window, document, platform, events) {
window.addEventListener('online', function (ev) {
events.publish('app:online', ev);
}, false);
window.addEventListener('offline', function (ev) {
events.publish('app:offline', ev);
}, false);
window.addEventListener('orientationchange', function (ev) {
events.publish('app:rotated', ev);
});
// When that status taps, we respond
window.addEventListener('statusTap', function (ev) {
// TODO: Make this more better
var el = document.elementFromPoint(platform.width() / 2, platform.height() / 2);
if (!el) {
return;
}
var content = dom_1.closest(el, 'scroll-content');
if (content) {
var scrollTo = new scroll_to_1.ScrollTo(content);
scrollTo.start(0, 0, 300, 0);
}
});
// start listening for resizes XXms after the app starts
setTimeout(function () {
window.addEventListener('resize', function () {
platform.windowResize();
});
}, 2000);
}
/***/ },
/* 3 */
/***/ function(module, exports) {
module.exports = require("angular2")["core"];
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = require("angular2")["router"];
/***/ },
/* 5 */
/***/ function(module, exports) {
module.exports = require("angular2")["http"];
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
var __decorate = (this && this.__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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = __webpack_require__(3);
var browser_1 = __webpack_require__(7);
var config_1 = __webpack_require__(8);
var click_block_1 = __webpack_require__(12);
var dom_1 = __webpack_require__(11);
/**
* @private
* Component registry service. For more information on registering
* components see the [IdRef API reference](../id/IdRef/).
*/
var IonicApp = (function () {
function IonicApp(_config, _clickBlock, _zone) {
this._config = _config;
this._clickBlock = _clickBlock;
this._zone = _zone;
this._titleSrv = new browser_1.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.
*/
IonicApp.prototype.setTitle = function (val) {
var self = this;
if (val !== self._title) {
self._title = val;
this._zone.runOutsideAngular(function () {
function setAppTitle() {
self._titleSrv.setTitle(self._title);
}
dom_1.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.
*/
IonicApp.prototype.setEnabled = function (isEnabled, duration) {
if (duration === void 0) { duration = 700; }
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}
*/
IonicApp.prototype.isEnabled = function () {
return (this._disTime < Date.now());
};
/**
* @private
*/
IonicApp.prototype.setScrolling = function () {
this._scrollTime = Date.now();
};
/**
* @private
* Boolean if the app is actively scrolling or not.
* @return {bool}
*/
IonicApp.prototype.isScrolling = function () {
return (this._scrollTime + 64 > Date.now());
};
/**
* @private
* Register a known component with a key, for easy lookups later.
* @param {string} id The id to use to register the component
* @param {Object} component The component to register
*/
IonicApp.prototype.register = function (id, component) {
if (this.components[id] && this.components[id] !== component) {
}
this.components[id] = component;
};
/**
* @private
* Unregister a known component with a key.
* @param {string} id The id to use to unregister
*/
IonicApp.prototype.unregister = function (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 {Object} the matching component, or undefined if none was found
*/
IonicApp.prototype.getRegisteredComponent = function (cls) {
for (var key in this.components) {
var component = this.components[key];
if (component instanceof cls) {
return component;
}
}
};
/**
* @private
* Get the component for the given key.
* @param {string} id TODO
* @return {Object} TODO
*/
IonicApp.prototype.getComponent = function (id) {
return this.components[id];
};
IonicApp = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [(typeof (_a = typeof config_1.Config !== 'undefined' && config_1.Config) === 'function' && _a) || Object, (typeof (_b = typeof click_block_1.ClickBlock !== 'undefined' && click_block_1.ClickBlock) === 'function' && _b) || Object, (typeof (_c = typeof core_1.NgZone !== 'undefined' && core_1.NgZone) === 'function' && _c) || Object])
], IonicApp);
return IonicApp;
var _a, _b, _c;
})();
exports.IonicApp = IonicApp;
/***/ },
/* 7 */
/***/ function(module, exports) {
module.exports = require("angular2")["platform"]["browser"];
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
/**
* @ngdoc service
* @name Config
* @module ionic
* @description
* Config allows you to set the modes of your components
*/
var platform_1 = __webpack_require__(9);
var util_1 = __webpack_require__(10);
/**
* @name Config
* @demo /docs/v2/demos/config/
* @description
* Config lets you change multiple or a single value in an apps mode configuration. Things such as tab placement, icon changes, and view animations can be set here.
*
* ```ts
* @App({
* template: `<ion-nav [root]="root"></ion-nav>`
* config: {
* backButtonText: 'Go Back',
* iconMode: 'ios',
* modalEnter: 'modal-slide-in',
* modalLeave: 'modal-slide-out',
* tabbarPlacement: 'bottom',
* pageTransition: 'ios',
* }
* })
* ```
*
* Config can be overwritting at multiple levels, allowing deeper configuration. Taking the example from earlier, we can override any setting we want based on a platform.
* ```ts
* @App({
* template: `<ion-nav [root]="root"></ion-nav>`
* config: {
* tabbarPlacement: 'bottom',
* platforms: {
* ios: {
* tabbarPlacement: 'top',
* }
* }
* }
* })
* ```
*
* We could also configure these values at a component level. Take `tabbarPlacement`, we can configure this as a property on our `ion-tabs`.
*
* ```html
* <ion-tabs tabbarPlacement="top">
* <ion-tab tabTitle="Dash" tabIcon="pulse" [root]="tabRoot"></ion-tab>
* </ion-tabs>
* ```
*
* The property will override anything else set in the apps.
*
* The last way we could configure is through URL query strings. This is useful for testing while in the browser.
* Simply add `?ionic<PROPERTYNAME>=<value>` to the url.
*
* ```bash
* http://localhost:8100/?ionicTabbarPlacement=bottom
* ```
*
* Custom values can be added to config, and looked up at a later point in time.
*
* ``` javascript
* config.set('ios', 'favoriteColor', 'green');
* // from any page in your app:
* config.get('favoriteColor'); // 'green'
* ```
*
*
* A config value can come from anywhere and be anything, but there are a default set of values.
*
*
* | Config property | Default iOS Value | Default MD Value |
* |----------------------------|------------------------|---------------------------|
* | activator | highlight | ripple |
* | actionSheetEnter | action-sheet-slide-in | action-sheet-md-slide-in |
* | actionSheetLeave | action-sheet-slide-out | action-sheet-md-slide-out |
* | alertEnter | alert-pop-in | alert-md-pop-in |
* | alertLeave | alert-pop-out | alert-md-pop-out |
* | backButtonText | Back | |
* | backButtonIcon | ion-ios-arrow-back | ion-md-arrow-back |
* | iconMode | ios | md |
* | menuType | reveal | overlay |
* | modalEnter | modal-slide-in | modal-md-slide-in |
* | modalLeave | modal-slide-out | modal-md-slide-out |
* | pageTransition | ios-transition | md-transition |
* | pageTransitionDelay | 16 | 120 |
* | tabbarPlacement | bottom | top |
* | tabbarHighlight | | top |
* | tabSubPages | | true |
*
**/
var Config = (function () {
function Config(config) {
this._c = {};
this._s = {};
this._s = config && util_1.isObject(config) && !util_1.isArray(config) ? config : {};
}
/**
* For setting and getting multiple config values
*/
/**
* @private
* @name settings()
* @description
*/
Config.prototype.settings = function () {
var args = arguments;
switch (args.length) {
case 0:
return this._s;
case 1:
// settings({...})
this._s = args[0];
this._c = {}; // clear cache
break;
case 2:
// settings('ios', {...})
this._s.platforms = this._s.platforms || {};
this._s.platforms[args[0]] = args[1];
this._c = {}; // clear cache
break;
}
return this;
};
/**
* @name set
* @description
* Sets a single config value.
*
* @param {String} [platform] - The platform (either 'ios' or 'android') that the config value should apply to. Leaving this blank will apply the config value to all platforms.
* @param {String} [key] - The key used to look up the value at a later point in time.
* @param {String} [value] - The config value being stored.
*/
Config.prototype.set = function () {
var args = arguments;
var arg0 = args[0];
var arg1 = args[1];
switch (args.length) {
case 2:
// set('key', 'value') = set key/value pair
// arg1 = value
this._s[arg0] = arg1;
delete this._c[arg0]; // clear cache
break;
case 3:
// setting('ios', 'key', 'value') = set key/value pair for platform
// arg0 = platform
// arg1 = key
// arg2 = value
this._s.platforms = this._s.platforms || {};
this._s.platforms[arg0] = this._s.platforms[arg0] || {};
this._s.platforms[arg0][arg1] = args[2];
delete this._c[arg1]; // clear cache
break;
}
return this;
};
/**
* @name get
* @description
* Returns a single config value, given a key.
*
* @param {String} [key] - the key for the config value
*/
Config.prototype.get = function (key) {
if (!util_1.isDefined(this._c[key])) {
if (!util_1.isDefined(key)) {
throw 'config key is not defined';
}
// if the value was already set this will all be skipped
// if there was no user config then it'll check each of
// the user config's platforms, which already contains
// settings from default platform configs
var userPlatformValue = undefined;
var userDefaultValue = this._s[key];
var userPlatformModeValue = undefined;
var userDefaultModeValue = undefined;
var platformValue = undefined;
var platformModeValue = undefined;
var configObj = null;
if (this.platform) {
var queryStringValue = this.platform.query('ionic' + key.toLowerCase());
if (util_1.isDefined(queryStringValue)) {
return this._c[key] = (queryStringValue === 'true' ? true : queryStringValue === 'false' ? false : queryStringValue);
}
// check the platform settings object for this value
// loop though each of the active platforms
// array of active platforms, which also knows the hierarchy,
// with the last one the most important
var activePlatformKeys = this.platform.platforms();
// loop through all of the active platforms we're on
for (var i = 0, l = activePlatformKeys.length; i < l; i++) {
// get user defined platform values
if (this._s.platforms) {
configObj = this._s.platforms[activePlatformKeys[i]];
if (configObj) {
if (util_1.isDefined(configObj[key])) {
userPlatformValue = configObj[key];
}
configObj = Config.getModeConfig(configObj.mode);
if (configObj && util_1.isDefined(configObj[key])) {
userPlatformModeValue = configObj[key];
}
}
}
// get default platform's setting
configObj = platform_1.Platform.get(activePlatformKeys[i]);
if (configObj && configObj.settings) {
if (util_1.isDefined(configObj.settings[key])) {
// found a setting for this platform
platformValue = configObj.settings[key];
}
configObj = Config.getModeConfig(configObj.settings.mode);
if (configObj && util_1.isDefined(configObj[key])) {
// found setting for this platform's mode
platformModeValue = configObj[key];
}
}
}
}
configObj = Config.getModeConfig(this._s.mode);
if (configObj && util_1.isDefined(configObj[key])) {
userDefaultModeValue = configObj[key];
}
// cache the value
this._c[key] = util_1.isDefined(userPlatformValue) ? userPlatformValue :
util_1.isDefined(userDefaultValue) ? userDefaultValue :
util_1.isDefined(userPlatformModeValue) ? userPlatformModeValue :
util_1.isDefined(userDefaultModeValue) ? userDefaultModeValue :
util_1.isDefined(platformValue) ? platformValue :
util_1.isDefined(platformModeValue) ? platformModeValue :
null;
}
// return key's value
// either it came directly from the user config
// or it was from the users platform configs
// or it was from the default platform configs
// in that order
if (util_1.isFunction(this._c[key])) {
return this._c[key](this.platform);
}
return this._c[key];
};
Config.prototype.getBoolean = function (key) {
var val = this.get(key);
return (val || val === 'true') ? true : false;
};
/**
* @private
*/
Config.prototype.setPlatform = function (platform) {
this.platform = platform;
};
Config.setModeConfig = function (mode, config) {
modeConfigs[mode] = config;
};
Config.getModeConfig = function (mode) {
return modeConfigs[mode] || null;
};
return Config;
})();
exports.Config = Config;
var modeConfigs = {};
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
var util_1 = __webpack_require__(10);
var dom_1 = __webpack_require__(11);
/**
* @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/v2/demos/platform/
*/
var Platform = (function () {
function Platform(platforms) {
var _this = this;
if (platforms === void 0) { platforms = []; }
this._versions = {};
this._onResizes = [];
this._platforms = platforms;
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
* }
* }
* }
* ```
*/
Platform.prototype.is = function (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
* }
* }
* ```
*/
Platform.prototype.platforms = function () {
// 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
*
*/
Platform.prototype.versions = function (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
*/
Platform.prototype.version = function () {
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
*/
Platform.prototype.ready = function () {
return this._readyPromise;
};
/**
* @private
*/
Platform.prototype.prepareReady = function (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
dom_1.ready(resolve);
}
};
/**
* Set the app's language direction, which will update the `dir` attribute
* on the app's root `<html>` element. We recommend the app's `index.html`
* file already has the correct `dir` attribute value set, such as
* `<html dir="ltr">` or `<html dir="rtl">`. 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`
*/
Platform.prototype.setDir = function (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 `<html dir="ltr">` or `<html dir="rtl">`.
* [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
* @returns {string}
*/
Platform.prototype.dir = function () {
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 `<html dir="ltr">` or `<html dir="rtl">`.
* [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
* @returns {boolean}
*/
Platform.prototype.isRTL = function () {
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 `<html>` element.
* We recommend the app's `index.html` file already has the correct `lang`
* attribute value set, such as `<html lang="en">`. 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`
*/
Platform.prototype.setLang = function (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 `<html lang="en">`.
* [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)
* @returns {string}
*/
Platform.prototype.lang = function () {
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
*/
Platform.prototype.on = function () { };
/**
* @private
*/
Platform.prototype.onHardwareBackButton = function () { };
/**
* @private
*/
Platform.prototype.registerBackButtonAction = function () { };
/**
* @private
*/
Platform.prototype.exitApp = function () { };
/**
* @private
*/
Platform.prototype.fullScreen = function () { };
/**
* @private
*/
Platform.prototype.showStatusBar = function () { };
// Getter/Setter Methods
// **********************************************
/**
* @private
*/
Platform.prototype.setUrl = function (url) {
this._url = url;
this._qs = util_1.getQuerystring(url);
};
/**
* @private
*/
Platform.prototype.url = function () {
return this._url;
};
/**
* @private
*/
Platform.prototype.query = function (key) {
return (this._qs || {})[key];
};
/**
* @private
*/
Platform.prototype.setUserAgent = function (userAgent) {
this._ua = userAgent;
};
/**
* @private
*/
Platform.prototype.userAgent = function () {
return this._ua || '';
};
/**
* @private
*/
Platform.prototype.setNavigatorPlatform = function (navigatorPlatform) {
this._bPlt = navigatorPlatform;
};
/**
* @private
*/
Platform.prototype.navigatorPlatform = function () {
return this._bPlt || '';
};
/**
* @private
*/
Platform.prototype.width = function () {
return dom_1.windowDimensions().width;
};
/**
* @private
*/
Platform.prototype.height = function () {
return dom_1.windowDimensions().height;
};
/**
* @private
*/
Platform.prototype.isPortrait = function () {
return this.width() < this.height();
};
/**
* @private
*/
Platform.prototype.isLandscape = function () {
return !this.isPortrait();
};
/**
* @private
*/
Platform.prototype.windowResize = function () {
var self = this;
clearTimeout(self._resizeTimer);
self._resizeTimer = setTimeout(function () {
dom_1.flushDimensionCache();
for (var i = 0; i < self._onResizes.length; i++) {
try {
self._onResizes[i]();
}
catch (e) {
void 0;
}
}
}, 250);
};
/**
* @private
*/
Platform.prototype.onResize = function (cb) {
this._onResizes.push(cb);
};
// Platform Registry
// **********************************************
/**
* @private
*/
Platform.register = function (platformConfig) {
platformRegistry[platformConfig.name] = platformConfig;
};
/**
* @private
*/
Platform.registry = function () {
return platformRegistry;
};
/**
* @private
*/
Platform.get = function (platformName) {
return platformRegistry[platformName] || {};
};
/**
* @private
*/
Platform.setDefault = function (platformName) {
platformDefault = platformName;
};
/**
* @private
*/
Platform.prototype.testQuery = function (queryValue, queryTestValue) {
var valueSplit = queryValue.toLowerCase().split(';');
return valueSplit.indexOf(queryTestValue) > -1;
};
/**
* @private
*/
Platform.prototype.testUserAgent = function (userAgentExpression) {
var rgx = new RegExp(userAgentExpression, 'i');
return rgx.test(this._ua || '');
};
/**
* @private
*/
Platform.prototype.testNavigatorPlatform = function (navigatorPlatformExpression) {
var rgx = new RegExp(navigatorPlatformExpression, 'i');
return rgx.test(this._bPlt);
};
/**
* @private
*/
Platform.prototype.matchUserAgentVersion = function (userAgentExpression) {
if (this._ua && userAgentExpression) {
var val = this._ua.match(userAgentExpression);
if (val) {
return {
major: val[1],
minor: val[2]
};
}
}
};
/**
* @private
*/
Platform.prototype.isPlatform = function (queryTestValue, userAgentExpression) {
if (!userAgentExpression) {
userAgentExpression = queryTestValue;
}
var queryValue = this.query('ionicplatform');
if (queryValue) {
return this.testQuery(queryValue, queryTestValue);
}
return this.testUserAgent(userAgentExpression);
};
/**
* @private
*/
Platform.prototype.load = function (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;
util_1.assign(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
*/
Platform.prototype.matchPlatform = function (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);
if (rootNode) {
rootNode.depth = 0;
var childPlatform = rootNode.child;
while (childPlatform) {
rootNode.depth++;
childPlatform = childPlatform.child;
}
}
return rootNode;
};
return Platform;
})();
exports.Platform = Platform;
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;
}
}
var PlatformNode = (function () {
function PlatformNode(platformName) {
this.c = Platform.get(platformName);
this.isEngine = this.c.isEngine;
}
PlatformNode.prototype.name = function () {
return this.c.name;
};
PlatformNode.prototype.settings = function () {
return this.c.settings || {};
};
PlatformNode.prototype.superset = function () {
return this.c.superset;
};
PlatformNode.prototype.methods = function () {
return this.c.methods || {};
};
PlatformNode.prototype.isMatch = function (p) {
if (p.platformOverride && !this.isEngine) {
return (p.platformOverride === this.c.name);
}
else if (!this.c.isMatch) {
return false;
}
return this.c.isMatch(p);
};
PlatformNode.prototype.version = function (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)
};
}
}
};
PlatformNode.prototype.getRoot = function (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;
};
PlatformNode.prototype.getSubsetParents = function (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;
})();
var platformRegistry = {};
var platformDefault = null;
/***/ },
/* 10 */
/***/ function(module, exports) {
// Simple noop function
function noop() { }
exports.noop = 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));
}
exports.clamp = clamp;
/**
* The assign() method is used to copy the values of all enumerable own
* properties from one or more source objects to a target object. It will
* return the target object. When available, this method will use
* `Object.assign()` under-the-hood.
* @param target The target object
* @param source(s) The source object
*/
function assign() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
if (typeof Object.assign !== 'function') {
// use the old-school shallow extend method
return _baseExtend(args[0], [].slice.call(args, 1), false);
}
// use the built in ES6 Object.assign method
return Object.assign.apply(null, args);
}
exports.assign = assign;
/**
* Do a deep extend (merge).
* @param dst the destination
* @param ... the param objects
*/
function merge(dst) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return _baseExtend(dst, [].slice.call(arguments, 1), true);
}
exports.merge = merge;
function _baseExtend(dst, objs, deep) {
for (var i = 0, ii = objs.length; i < ii; ++i) {
var obj = objs[i];
if (!obj || !exports.isObject(obj) && !exports.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 && exports.isObject(src)) {
if (!exports.isObject(dst[key]))
dst[key] = exports.isArray(src) ? [] : {};
_baseExtend(dst[key], [src], true);
}
else {
dst[key] = src;
}
}
}
return dst;
}
function debounce(func, wait, immediate) {
if (immediate === void 0) { immediate = false; }
var timeout, args, context, timestamp, result;
return function () {
context = this;
args = arguments;
timestamp = Date.now();
var later = function () {
var last = Date.now() - 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;
};
}
exports.debounce = debounce;
/**
* Apply default arguments if they don't exist in
* the first object.
* @param the destination to apply defaults to.
*/
function defaults(dest) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
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;
}
exports.defaults = defaults;
exports.isBoolean = function (val) { return typeof val === 'boolean'; };
exports.isString = function (val) { return typeof val === 'string'; };
exports.isNumber = function (val) { return typeof val === 'number'; };
exports.isFunction = function (val) { return typeof val === 'function'; };
exports.isDefined = function (val) { return typeo