UNPKG

ionic-framework

Version:
1,404 lines (1,368 loc) 776 kB
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__(41)); __export(__webpack_require__(44)); __export(__webpack_require__(79)); __export(__webpack_require__(9)); __export(__webpack_require__(81)); __export(__webpack_require__(12)); __export(__webpack_require__(34)); __export(__webpack_require__(16)); __export(__webpack_require__(20)); __export(__webpack_require__(36)); __export(__webpack_require__(85)); // these modules don't export anything __webpack_require__(86); __webpack_require__(87); __webpack_require__(88); __webpack_require__(89); __webpack_require__(90); /***/ }, /* 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 overlay_controller_1 = __webpack_require__(13); var form_1 = __webpack_require__(15); var keyboard_1 = __webpack_require__(16); var action_sheet_1 = __webpack_require__(17); var modal_1 = __webpack_require__(31); var popup_1 = __webpack_require__(32); var events_1 = __webpack_require__(34); var nav_registry_1 = __webpack_require__(35); var translate_1 = __webpack_require__(36); var click_block_1 = __webpack_require__(12); var feature_detect_1 = __webpack_require__(37); var tap_click_1 = __webpack_require__(38); var dom_1 = __webpack_require__(11); 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.url(window.location.href); platform.userAgent(window.navigator.userAgent); platform.navigatorPlatform(window.navigator.platform); platform.load(); config.setPlatform(platform); var clickBlock = new click_block_1.ClickBlock(config.get('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, overlay_controller_1.OverlayController, action_sheet_1.ActionSheet, modal_1.Modal, popup_1.Popup, 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); 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 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); /** * 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._zone = zone; this._titleSrv = new browser_1.Title(); this._title = ''; this._disTime = 0; this._clickBlock = clickBlock; // 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); }); } }; /** * 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); } }; /** * Boolean if the app is actively enabled or not. * @return {bool} */ IonicApp.prototype.isEnabled = function () { return (this._disTime < Date.now()); }; /** * 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 */ IonicApp.prototype.register = function (id, component) { if (this.components[id] && this.components[id] !== component) { } this.components[id] = component; }; /** * Unregister a known component with a key. * @param {TODO} id The id to use to unregister */ IonicApp.prototype.unregister = function (id) { delete this.components[id]; }; /** * 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 */ IonicApp.prototype.getRegisteredComponent = function (cls) { for (var _i = 0, _a = this.components; _i < _a.length; _i++) { var component = _a[_i]; if (component instanceof cls) { return component; } } }; /** * Get the component for the given key. * @param {TODO} key TODO * @return {TODO} 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); /** * 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 tabbar-placement="top"> * <ion-tab tab-title="Dash" tab-icon="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 * ``` * * A config value can come from anywhere and be anything, but there are a default set of values. * * ``` javascript * // iOS * activator: 'highlight', * actionSheetEnter: 'action-sheet-slide-in', * actionSheetLeave: 'action-sheet-slide-out', * actionSheetCancelIcon: '', * actionSheetDestructiveIcon: '', * backButtonText: 'Back', * backButtonIcon: 'ion-ios-arrow-back', * iconMode: 'ios', * menuType: 'reveal', * modalEnter: 'modal-slide-in', * modalLeave: 'modal-slide-out', * pageTransition: 'ios-transition', * pageTransitionDelay: 16, * popupEnter: 'popup-pop-in', * popupLeave: 'popup-pop-out', * tabbarPlacement: 'bottom', * // MD * activator: 'ripple', * actionSheetEnter: 'action-sheet-md-slide-in', * actionSheetLeave: 'action-sheet-md-slide-out', * actionSheetCancelIcon: 'ion-md-close', * actionSheetDestructiveIcon: 'ion-md-trash', * backButtonText: '', * backButtonIcon: 'ion-md-arrow-back', * iconMode: 'md', * menuType: 'overlay', * modalEnter: 'modal-md-slide-in', * modalLeave: 'modal-md-slide-out', * pageTransition: 'md-transition', * pageTransitionDelay: 120, * popupEnter: 'popup-md-pop-in', * popupLeave: 'popup-md-pop-out', * tabbarHighlight: true, * tabbarPlacement: 'top', * tabSubPages: true, * ``` * * **/ var Config = (function () { function Config(config) { this._s = config && util_1.isObject(config) && !util_1.isArray(config) ? config : {}; this._c = {}; // cached values } /** * 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; }; /** * For setting a single config values */ /** * @private * @name set() * @description */ 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; }; /** * For getting a single config values */ /** * @private * @name get() * @description */ Config.prototype.get = function (key) { if (!util_1.isDefined(this._c[key])) { // 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]; }; /** * @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__) { /** +* @ngdoc service +* @name platform +* @module ionic +* @description +* Platform returns the availble information about your current platform +*/ var util_1 = __webpack_require__(10); var dom_1 = __webpack_require__(11); /** * TODO */ var Platform = (function () { function Platform(platforms) { var _this = this; if (platforms === void 0) { platforms = []; } this._platforms = platforms; this._versions = {}; 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 * } * } * } * ``` */ 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; }; /** * @param {string} optional platformName * @returns {object} An object with various platform info * - `{object=} `cordova` * - `{object=}` `platformOS` {str: "9.1", num: 9.1, major: 9, minor: 1} * - `{object=} `deviceName` Returns the name of the device * - `{object=}` `device platform` R * @description * Returns an object conta * * ``` * import {Platform} 'ionic/ionic'; * export MyClass { * constructor(platform: Platform){ * this.platform = platform; * console.log(this.platform.versions()); * // or pass in a platform name * console.log(this.platform.versions('ios')); * } * } * ``` * */ 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; }; Platform.prototype.version = function () { for (var platformName in this._versions) { if (this._versions[platformName]) { return this._versions[platformName]; } } return {}; }; /** * @returns {promise} * @description * 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 * }); * } * } * ``` */ Platform.prototype.ready = function () { return this._readyPromise; }; /** * @private * TODO * @param {TODO} config TODO * @returns {TODO} TODO */ 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); } }; // 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 Platform.prototype.on = function () { }; Platform.prototype.onHardwareBackButton = function () { }; Platform.prototype.registerBackButtonAction = function () { }; Platform.prototype.exitApp = function () { }; Platform.prototype.fullScreen = function () { }; Platform.prototype.showStatusBar = function () { }; // Getter/Setter Methods // ********************************************** Platform.prototype.url = function (val) { if (arguments.length) { this._url = val; this._qs = util_1.getQuerystring(val); } return this._url; }; Platform.prototype.query = function (key) { return (this._qs || {})[key]; }; Platform.prototype.userAgent = function (val) { if (arguments.length) { this._ua = val; } return this._ua || ''; }; Platform.prototype.navigatorPlatform = function (val) { if (arguments.length) { this._bPlt = val; } return this._bPlt || ''; }; Platform.prototype.width = function () { return dom_1.windowDimensions().width; }; Platform.prototype.height = function () { return dom_1.windowDimensions().height; }; Platform.prototype.isPortrait = function () { return this.width() < this.height(); }; Platform.prototype.isLandscape = function () { return !this.isPortrait(); }; 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) { console.error(e); } } }, 500); }; Platform.prototype.onResize = function (cb) { this._onResizes.push(cb); }; // Platform Registry // ********************************************** /** * TODO * @param {TODO} platformConfig TODO */ Platform.register = function (platformConfig) { platformRegistry[platformConfig.name] = platformConfig; }; Platform.registry = function () { return platformRegistry; }; /** * TODO * @param {TODO} platformName TODO * @returns {string} TODO */ Platform.get = function (platformName) { return platformRegistry[platformName] || {}; }; Platform.setDefault = function (platformName) { platformDefault = platformName; }; /** * TODO * @param {TODO} queryValue TODO * @returns {boolean} TODO */ Platform.prototype.testQuery = function (queryValue, queryTestValue) { var valueSplit = queryValue.toLowerCase().split(';'); return valueSplit.indexOf(queryTestValue) > -1; }; /** * TODO * @param {TODO} userAgentExpression TODO * @returns {boolean} TODO */ Platform.prototype.testUserAgent = function (userAgentExpression) { var rgx = new RegExp(userAgentExpression, 'i'); return rgx.test(this._ua || ''); }; /** * TODO * @param {TODO} navigatorPlatformExpression TODO * @returns {boolean} TODO */ Platform.prototype.testNavigatorPlatform = function (navigatorPlatformExpression) { if (navigatorPlatformExpression && this._bPlt) { var rgx = new RegExp(navigatorPlatformExpression, 'i'); return rgx.test(this._bPlt); } }; /** * TODO * @param {TODO} userAgentExpression TODO * @returns {Object} TODO */ Platform.prototype.matchUserAgentVersion = function (userAgentExpression) { if (this._ua && userAgentExpression) { var val = this._ua.match(userAgentExpression); if (val) { return { major: val[1], minor: val[2] }; } } }; /** * TODO * @param {TODO} queryValue TODO * @param {TODO} userAgentExpression TODO * @returns {boolean} TODO */ 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); }; /** * TODO * @param {TODO} config TODO */ 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.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(); } } }; /** * TODO * @param {TODO} platformName TODO * @returns {TODO} TODO */ 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, 0); 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.parent = function (val) { if (arguments.length) { this._parent = val; } return this._parent; }; PlatformNode.prototype.child = function (val) { if (arguments.length) { this._child = val; } return this._child; }; 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; /** * Extend the destination with an arbitrary number of other objects. * @param dst the destination * @param ... the param objects */ function extend(dst) { return _baseExtend(dst, [].slice.call(arguments, 1), false); } exports.extend = extend; /** * Do a deep extend (merge). * @param dst the destination * @param ... the param objects */ function merge(dst) { 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) { var timeout, args, context, timestamp, result; return function () { context = this; args = arguments; timestamp = new Date(); var later = function () { 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; }; } 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) { 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 typeof val !== 'undefined'; }; exports.isUndefined = function (val) { return typeof val === 'undefined'; }; exports.isBlank = function (val) { return val === undefined || val === null; }; exports.isObject = function (val) { return typeof val === 'object'; }; exports.isArray = Array.isArray; exports.isTrueProperty = function (val) { return typeof val !== 'undefined' && val !== "false"; }; /** * Convert a string in the format thisIsAString to a slug format this-is-a-string */ function pascalCaseToDashCase(str) { if (str === void 0) { str = ''; } return str.charAt(0).toLowerCase() + str.substring(1).replace(/[A-Z]/g, function (match) { return '-' + match.toLowerCase(); }); } exports.pascalCaseToDashCase = pascalCaseToDashCase; var uid = 0; function nextUid() { return ++uid; } exports.nextUid = nextUid; exports.array = { find: function (arr, cb) { for (var i = 0, ii = arr.length; i < ii; i++) { if (cb(arr[i], i)) return arr[i]; } }, remove: function (arr, itemOrIndex) { var index = -1; if (exports.isNumber(itemOrIndex)) { index = itemOrIndex; } else { index = arr.indexOf(itemOrIndex); } if (index < 0) { return false; } arr.splice(index, 1); return true; } }; /** * 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; } exports.getQuerystring = getQuerystring; /** * Throttle the given fun, only allowing it to be * called at most every `wait` ms. */ function throttle(func, wait, options) { var context, args, result; var timeout = null; var previous = 0; options || (options = {}); var later = function () { 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; }; } exports.throttle = throttle; /***/ }, /* 11 */ /***/ function(module, exports) { var nativeRaf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; var nativeCancelRaf = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame; function raf(callback) { //console.log('raf', callback.toString().replace(/\s/g, '').replace('function', '').substring(0, 50)); //console.log('raf, isRootZone()', zone.isRootZone(), '$id', zone.$id); _raf(callback); } exports.raf = raf; var _raf = nativeRaf || function (callback) { var timeCurrent = (new Date()).getTime(), timeDelta; /* Dynamically set delay on a per-tick basis to match 60fps. */ /* Technique by Erik Moller. MIT license: https://gist.github.com/paulirish/1579671 */ timeDelta = Math.max(0, 16 - (timeCurrent - timeLast)); timeLast = timeCurrent + timeDelta; return setTimeout(function () { callback(timeCurrent + timeDelta); }, timeDelta); }; exports.rafCancel = nativeRaf ? nativeCancelRaf : function (id) { return window.cancelTimeout(id); }; function rafFrames(framesToWait, callback) { framesToWait = Math.ceil(framesToWait); if (framesToWait < 2) { raf(callback); } else { setTimeout(function () { raf(callback); }, (framesToWait - 1) * 17); } } exports.rafFrames = rafFrames; exports.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) { exports.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) { exports.CSS.transition = keys[i]; break; } } // The only prefix we care about is webkit for transitions. var isWebkit = exports.CSS.transition.indexOf('webkit') > -1; exports.CSS.prefix = isWebkit ? '-webkit-' : ''; // transition duration exports.CSS.transitionDuration = (isWebkit ? '-webkit-' : ''