diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2017-09-21 12:49:18 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2017-09-21 12:49:18 -0400 |
| commit | b28028ac4082842143b0f528d6bc539da6ccb419 (patch) | |
| tree | 1e26ea969a781ed8e323fca4e3c76345113fc694 /www/lib/ionic/js/ionic-angular.js | |
| parent | 676270d21beed31d767a06c89522198c77d5d865 (diff) | |
mega changes, including updates and X
Diffstat (limited to 'www/lib/ionic/js/ionic-angular.js')
| -rw-r--r-- | www/lib/ionic/js/ionic-angular.js | 639 |
1 files changed, 142 insertions, 497 deletions
diff --git a/www/lib/ionic/js/ionic-angular.js b/www/lib/ionic/js/ionic-angular.js index eba49d27..f3afedec 100644 --- a/www/lib/ionic/js/ionic-angular.js +++ b/www/lib/ionic/js/ionic-angular.js @@ -2,7 +2,7 @@ * Copyright 2015 Drifty Co. * http://drifty.com/ * - * Ionic, v1.3.3 + * Ionic, v1.2.4-nightly-1917 * A powerful HTML5 mobile app framework. * http://ionicframework.com/ * @@ -897,16 +897,6 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ // it's back view would be better represented using the current view as its back view tmp = getViewById(switchToView.backViewId); if (tmp && switchToView.historyId !== tmp.historyId) { - // the new view is being removed from it's old position in the history and being placed at the top, - // so we need to update any views that reference it as a backview, otherwise there will be infinitely loops - var viewIds = Object.keys(viewHistory.views); - viewIds.forEach(function(viewId) { - var view = viewHistory.views[viewId]; - if ((view.backViewId === switchToView.viewId) && (view.historyId !== switchToView.historyId)) { - view.backViewId = null; - } - }); - hist.stack[hist.cursor].backViewId = currentView.viewId; } @@ -915,6 +905,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ // create an element from the viewLocals template ele = $ionicViewSwitcher.createViewEle(viewLocals); if (this.isAbstractEle(ele, viewLocals)) { + void 0; return { action: 'abstractView', direction: DIRECTION_NONE, @@ -954,7 +945,6 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ direction = DIRECTION_FORWARD; } else if (currentView.historyId !== hist.historyId) { - // DB: this is a new view in a different tab direction = DIRECTION_ENTER; tmp = getHistoryById(currentView.historyId); @@ -1036,6 +1026,8 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ } } + void 0; + hist.cursor = viewHistory.currentView.index; return { @@ -1221,44 +1213,13 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ if (clearStateIds.length) { $timeout(function() { self.clearCache(clearStateIds); - }, 300); + }, 600); } } viewHistory.backView && viewHistory.backView.go(); }, - /** - * @ngdoc method - * @name $ionicHistory#removeBackView - * @description Remove the previous view from the history completely, including the - * cached element and scope (if they exist). - */ - removeBackView: function() { - var self = this; - var currentHistory = viewHistory.histories[this.currentHistoryId()]; - var currentCursor = currentHistory.cursor; - - var currentView = currentHistory.stack[currentCursor]; - var backView = currentHistory.stack[currentCursor - 1]; - var replacementView = currentHistory.stack[currentCursor - 2]; - - // fail if we dont have enough views in the history - if (!backView || !replacementView) { - return; - } - - // remove the old backView and the cached element/scope - currentHistory.stack.splice(currentCursor - 1, 1); - self.clearCache([backView.viewId]); - // make the replacementView and currentView point to each other (bypass the old backView) - currentView.backViewId = replacementView.viewId; - currentView.index = currentView.index - 1; - replacementView.forwardViewId = currentView.viewId; - // update the cursor and set new backView - viewHistory.backView = replacementView; - currentHistory.currentCursor += -1; - }, enabledBack: function(view) { var backView = getBackView(view); @@ -1425,10 +1386,6 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ if (ele && ele.attr('can-swipe-back') === 'false') { return false; } - var eleChild = ele.find('ion-view'); - if (eleChild && eleChild.attr('can-swipe-back') === 'false') { - return false; - } return true; } @@ -1538,7 +1495,7 @@ function($rootScope, $state, $location, $document, $ionicPlatform, $ionicHistory * $ionicConfigProvider.views.maxCache(10); * ``` * - * Additionally, each platform can have its own config within the `$ionicConfigProvider.platform` + * Additionally, each platform can have it's own config within the `$ionicConfigProvider.platform` * property. The config below would only apply to Android devices. * * ```js @@ -1602,16 +1559,6 @@ function($rootScope, $state, $location, $document, $ionicPlatform, $ionicHistory * @returns {boolean} */ - /** - * @ngdoc method - * @name $ionicConfigProvider#views.swipeBackEnabled - * @description By default on iOS devices, swipe to go back functionality is enabled by default. - * This method can be used to disable it globally, or on a per-view basis. - * Note: This functionality is only supported on iOS. - * @param {boolean} value - * @returns {boolean} - */ - /** * @ngdoc method * @name $ionicConfigProvider#scrolling.jsScrolling @@ -2011,28 +1958,27 @@ IonicModule provider.transitions.views.android = function(enteringEle, leavingEle, direction, shouldAnimate) { shouldAnimate = shouldAnimate && (direction == 'forward' || direction == 'back'); - function setStyles(ele, x, opacity) { + function setStyles(ele, x) { var css = {}; css[ionic.CSS.TRANSITION_DURATION] = d.shouldAnimate ? '' : 0; css[ionic.CSS.TRANSFORM] = 'translate3d(' + x + '%,0,0)'; - css.opacity = opacity; ionic.DomUtil.cachedStyles(ele, css); } var d = { run: function(step) { if (direction == 'forward') { - setStyles(enteringEle, (1 - step) * 99, 1); // starting at 98% prevents a flicker - setStyles(leavingEle, step * -100, 1); + setStyles(enteringEle, (1 - step) * 99); // starting at 98% prevents a flicker + setStyles(leavingEle, step * -100); } else if (direction == 'back') { - setStyles(enteringEle, (1 - step) * -100, 1); - setStyles(leavingEle, step * 100, 1); + setStyles(enteringEle, (1 - step) * -100); + setStyles(leavingEle, step * 100); } else { // swap, enter, exit - setStyles(enteringEle, 0, 1); - setStyles(leavingEle, 0, 0); + setStyles(enteringEle, 0); + setStyles(leavingEle, 0); } }, shouldAnimate: shouldAnimate @@ -2190,6 +2136,10 @@ var LOADING_TPL = '</div>' + '</div>'; +var LOADING_HIDE_DEPRECATED = '$ionicLoading instance.hide() has been deprecated. Use $ionicLoading.hide().'; +var LOADING_SHOW_DEPRECATED = '$ionicLoading instance.show() has been deprecated. Use $ionicLoading.show().'; +var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been deprecated. Use $ionicLoading.show({ template: \'my content\' }).'; + /** * @ngdoc service * @name $ionicLoading @@ -2204,16 +2154,11 @@ var LOADING_TPL = * .controller('LoadingCtrl', function($scope, $ionicLoading) { * $scope.show = function() { * $ionicLoading.show({ - * template: 'Loading...', - * duration: 3000 - * }).then(function(){ - * console.log("The loading indicator is now displayed"); + * template: 'Loading...' * }); * }; * $scope.hide = function(){ - * $ionicLoading.hide().then(function(){ - * console.log("The loading indicator is now hidden"); - * }); + * $ionicLoading.hide(); * }; * }); * ``` @@ -2233,10 +2178,7 @@ var LOADING_TPL = * }); * app.controller('AppCtrl', function($scope, $ionicLoading) { * $scope.showLoading = function() { - * //options default to values in $ionicLoadingConfig - * $ionicLoading.show().then(function(){ - * console.log("The loading indicator is now displayed"); - * }); + * $ionicLoading.show(); //options default to values in $ionicLoadingConfig * }; * }); * ``` @@ -2271,8 +2213,9 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, * @ngdoc method * @name $ionicLoading#show * @description Shows a loading indicator. If the indicator is already shown, - * it will set the options given and keep the indicator shown. - * @returns {promise} A promise which is resolved when the loading indicator is presented. + * it will set the options given and keep the indicator shown. Note: While this + * function still returns an $ionicLoading instance for backwards compatiblity, + * its use has been deprecated. * @param {object} opts The options for the loading indicator. Available properties: * - `{string=}` `template` The html content of the indicator. * - `{string=}` `templateUrl` The url of an html template to load as the content of the indicator. @@ -2289,7 +2232,6 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, * @ngdoc method * @name $ionicLoading#hide * @description Hides the loading indicator, if shown. - * @returns {promise} A promise which is resolved when the loading indicator is hidden. */ hide: hideLoader, /** @@ -2387,8 +2329,6 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, function showLoader(options) { options = extend({}, $ionicLoadingConfig || {}, options || {}); - // use a default delay of 100 to avoid some issues reported on github - // https://github.com/driftyco/ionic/issues/3717 var delay = options.delay || options.showDelay || 0; deregisterStateListener1(); @@ -2401,17 +2341,34 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, //If loading.show() was called previously, cancel it and show with our new options $timeout.cancel(loadingShowDelay); loadingShowDelay = $timeout(noop, delay); - return loadingShowDelay.then(getLoader).then(function(loader) { + loadingShowDelay.then(getLoader).then(function(loader) { return loader.show(options); }); + + return { + hide: function deprecatedHide() { + $log.error(LOADING_HIDE_DEPRECATED); + return hideLoader.apply(this, arguments); + }, + show: function deprecatedShow() { + $log.error(LOADING_SHOW_DEPRECATED); + return showLoader.apply(this, arguments); + }, + setContent: function deprecatedSetContent(content) { + $log.error(LOADING_SET_DEPRECATED); + return getLoader().then(function(loader) { + loader.show({ template: content }); + }); + } + }; } function hideLoader() { deregisterStateListener1(); deregisterStateListener2(); $timeout.cancel(loadingShowDelay); - return getLoader().then(function(loader) { - return loader.hide(); + getLoader().then(function(loader) { + loader.hide(); }); } }]); @@ -2420,7 +2377,6 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, * @ngdoc service * @name $ionicModal * @module ionic - * @codepen gblny * @description * * Related: {@link ionic.controller:ionicModal ionicModal controller}. @@ -2466,7 +2422,7 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, * $scope.closeModal = function() { * $scope.modal.hide(); * }; - * // Cleanup the modal when we're done with it! + * //Cleanup the modal when we're done with it! * $scope.$on('$destroy', function() { * $scope.modal.remove(); * }); @@ -2600,7 +2556,6 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl self.el.classList.add('active'); self.scope.$broadcast('$ionicHeader.align'); self.scope.$broadcast('$ionicFooter.align'); - self.scope.$broadcast('$ionic.modalPresented'); }, 20); return $timeout(function() { @@ -2643,8 +2598,6 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl if (self._isShown) return; modalEl.addClass('ng-leave-active') .removeClass('ng-enter ng-enter-active active'); - - self.scope.$broadcast('$ionic.modalRemoved'); }, 20, false); self.$el.off('click'); @@ -2660,9 +2613,7 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl } return $timeout(function() { - if (!modalStack.length) { - $ionicBody.removeClass(self.viewType + '-open'); - } + $ionicBody.removeClass(self.viewType + '-open'); self.el.classList.add('hide'); }, self.hideDelay || 320); }, @@ -2674,24 +2625,10 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl * @returns {promise} A promise which is resolved when the modal is finished animating out. */ remove: function() { - var self = this, - deferred, promise; + var self = this; self.scope.$parent && self.scope.$parent.$broadcast(self.viewType + '.removed', self); - // Only hide modal, when it is actually shown! - // The hide function shows a click-block-div for a split second, because on iOS, - // clicks will sometimes bleed through/ghost click on underlying elements. - // However, this will make the app unresponsive for short amount of time. - // We don't want that, if the modal window is already hidden. - if (self._isShown) { - promise = self.hide(); - } else { - deferred = $$q.defer(); - deferred.resolve(); - promise = deferred.promise; - } - - return promise.then(function() { + return self.hide().then(function() { self.scope.$destroy(); self.$el.remove(); }); @@ -3017,8 +2954,8 @@ IonicModule * @description * Add Cordova event listeners, such as `pause`, `resume`, `volumedownbutton`, `batterylow`, * `offline`, etc. More information about available event types can be found in - * [Cordova's event documentation](https://cordova.apache.org/docs/en/latest/cordova/events/events.html). - * @param {string} type Cordova [event type](https://cordova.apache.org/docs/en/latest/cordova/events/events.html). + * [Cordova's event documentation](https://cordova.apache.org/docs/en/edge/cordova_events_events.md.html#Events). + * @param {string} type Cordova [event type](https://cordova.apache.org/docs/en/edge/cordova_events_events.md.html#Events). * @param {function} callback Called when the Cordova event is fired. * @returns {function} Returns a deregistration function to remove the event listener. */ @@ -3046,11 +2983,6 @@ IonicModule var q = $q.defer(); ionic.Platform.ready(function() { - - window.addEventListener('statusTap', function() { - $ionicScrollDelegate.scrollTop(true); - }); - q.resolve(); cb && cb(); }); @@ -3059,6 +2991,10 @@ IonicModule } }; + window.addEventListener('statusTap', function() { + $ionicScrollDelegate.scrollTop(true); + }); + return self; }] }; @@ -3129,7 +3065,7 @@ IonicModule * $scope.$on('$destroy', function() { * $scope.popover.remove(); * }); - * // Execute action on hidden popover + * // Execute action on hide popover * $scope.$on('popover.hidden', function() { * // Execute action * }); @@ -4006,7 +3942,6 @@ IonicModule * @returns {object} The scroll position of this view, with the following properties: * - `{number}` `left` The distance the user has scrolled from the left (starts at 0). * - `{number}` `top` The distance the user has scrolled from the top (starts at 0). - * - `{number}` `zoom` The current zoom level. */ 'getScrollPosition', /** @@ -4884,67 +4819,32 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe }, - emit: function(step, enteringData, leavingData) { - var enteringScope = getScopeForElement(enteringEle, enteringData); - var leavingScope = getScopeForElement(leavingEle, leavingData); + emit: function(step, enteringData, leavingData) { + var enteringScope = enteringEle.scope(), + leavingScope = leavingEle && leavingEle.scope(); - var prefixesAreEqual; - - if ( !enteringData.viewId || enteringData.abstractView ) { - // it's an abstract view, so treat it accordingly + if (step == 'after') { + if (enteringScope) { + enteringScope.$emit('$ionicView.enter', enteringData); + } - // we only get access to the leaving scope once in the transition, - // so dispatch all events right away if it exists - if ( leavingScope ) { - leavingScope.$emit('$ionicView.beforeLeave', leavingData); + if (leavingScope) { leavingScope.$emit('$ionicView.leave', leavingData); - leavingScope.$emit('$ionicView.afterLeave', leavingData); - leavingScope.$broadcast('$ionicParentView.beforeLeave', leavingData); - leavingScope.$broadcast('$ionicParentView.leave', leavingData); - leavingScope.$broadcast('$ionicParentView.afterLeave', leavingData); + + } else if (enteringScope && leavingData && leavingData.viewId) { + enteringScope.$emit('$ionicNavView.leave', leavingData); } } - else { - // it's a regular view, so do the normal process - if (step == 'after') { - if (enteringScope) { - enteringScope.$emit('$ionicView.enter', enteringData); - enteringScope.$broadcast('$ionicParentView.enter', enteringData); - } - if (leavingScope) { - leavingScope.$emit('$ionicView.leave', leavingData); - leavingScope.$broadcast('$ionicParentView.leave', leavingData); - } - else if (enteringScope && leavingData && leavingData.viewId && enteringData.stateName !== leavingData.stateName) { - // we only want to dispatch this when we are doing a single-tier - // state change such as changing a tab, so compare the state - // for the same state-prefix but different suffix - prefixesAreEqual = compareStatePrefixes(enteringData.stateName, leavingData.stateName); - if ( prefixesAreEqual ) { - enteringScope.$emit('$ionicNavView.leave', leavingData); - } - } - } + if (enteringScope) { + enteringScope.$emit('$ionicView.' + step + 'Enter', enteringData); + } - if (enteringScope) { - enteringScope.$emit('$ionicView.' + step + 'Enter', enteringData); - enteringScope.$broadcast('$ionicParentView.' + step + 'Enter', enteringData); - } + if (leavingScope) { + leavingScope.$emit('$ionicView.' + step + 'Leave', leavingData); - if (leavingScope) { - leavingScope.$emit('$ionicView.' + step + 'Leave', leavingData); - leavingScope.$broadcast('$ionicParentView.' + step + 'Leave', leavingData); - - } else if (enteringScope && leavingData && leavingData.viewId && enteringData.stateName !== leavingData.stateName) { - // we only want to dispatch this when we are doing a single-tier - // state change such as changing a tab, so compare the state - // for the same state-prefix but different suffix - prefixesAreEqual = compareStatePrefixes(enteringData.stateName, leavingData.stateName); - if ( prefixesAreEqual ) { - enteringScope.$emit('$ionicNavView.' + step + 'Leave', leavingData); - } - } + } else if (enteringScope && leavingData && leavingData.viewId) { + enteringScope.$emit('$ionicNavView.' + step + 'Leave', leavingData); } }, @@ -5028,15 +4928,6 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe containerEle.innerHTML = viewLocals.$template; if (containerEle.children.length === 1) { containerEle.children[0].classList.add('pane'); - if ( viewLocals.$$state && viewLocals.$$state.self && viewLocals.$$state.self['abstract'] ) { - angular.element(containerEle.children[0]).attr("abstract", "true"); - } - else { - if ( viewLocals.$$state && viewLocals.$$state.self ) { - angular.element(containerEle.children[0]).attr("state", viewLocals.$$state.self.name); - } - - } return jqLite(containerEle.children[0]); } } @@ -5121,69 +5012,6 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe } } - function compareStatePrefixes(enteringStateName, exitingStateName) { - var enteringStateSuffixIndex = enteringStateName.lastIndexOf('.'); - var exitingStateSuffixIndex = exitingStateName.lastIndexOf('.'); - - // if either of the prefixes are empty, just return false - if ( enteringStateSuffixIndex < 0 || exitingStateSuffixIndex < 0 ) { - return false; - } - - var enteringPrefix = enteringStateName.substring(0, enteringStateSuffixIndex); - var exitingPrefix = exitingStateName.substring(0, exitingStateSuffixIndex); - - return enteringPrefix === exitingPrefix; - } - - function getScopeForElement(element, stateData) { - if ( !element ) { - return null; - } - // check if it's abstract - var attributeValue = angular.element(element).attr("abstract"); - var stateValue = angular.element(element).attr("state"); - - if ( attributeValue !== "true" ) { - // it's not an abstract view, so make sure the element - // matches the state. Due to abstract view weirdness, - // sometimes it doesn't. If it doesn't, don't dispatch events - // so leave the scope undefined - if ( stateValue === stateData.stateName ) { - return angular.element(element).scope(); - } - return null; - } - else { - // it is an abstract element, so look for element with the "state" attributeValue - // set to the name of the stateData state - var elements = aggregateNavViewChildren(element); - for ( var i = 0; i < elements.length; i++ ) { - var state = angular.element(elements[i]).attr("state"); - if ( state === stateData.stateName ) { - stateData.abstractView = true; - return angular.element(elements[i]).scope(); - } - } - // we didn't find a match, so return null - return null; - } - } - - function aggregateNavViewChildren(element) { - var aggregate = []; - var navViews = angular.element(element).find("ion-nav-view"); - for ( var i = 0; i < navViews.length; i++ ) { - var children = angular.element(navViews[i]).children(); - var childrenAggregated = []; - for ( var j = 0; j < children.length; j++ ) { - childrenAggregated = childrenAggregated.concat(children[j]); - } - aggregate = aggregate.concat(childrenAggregated); - } - return aggregate; - } - }]); /** @@ -5414,20 +5242,10 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) { self.titleTextWidth = function() { - var element = getEle(TITLE); - if ( element ) { - // If the element has a nav-bar-title, use that instead - // to calculate the width of the title - var children = angular.element(element).children(); - for ( var i = 0; i < children.length; i++ ) { - if ( angular.element(children[i]).hasClass('nav-bar-title') ) { - element = children[i]; - break; - } - } + if (!titleTextWidth) { + var bounds = ionic.DomUtil.getTextBounds(getEle(TITLE)); + titleTextWidth = Math.min(bounds && bounds.width || 30); } - var bounds = ionic.DomUtil.getTextBounds(element); - titleTextWidth = Math.min(bounds && bounds.width || 30); return titleTextWidth; }; @@ -6465,8 +6283,7 @@ IonicModule '$ionicViewSwitcher', '$ionicConfig', '$ionicScrollDelegate', - '$ionicSideMenuDelegate', -function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate, $ionicNavViewDelegate, $ionicHistory, $ionicViewSwitcher, $ionicConfig, $ionicScrollDelegate, $ionicSideMenuDelegate) { +function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate, $ionicNavViewDelegate, $ionicHistory, $ionicViewSwitcher, $ionicConfig, $ionicScrollDelegate) { var DATA_ELE_IDENTIFIER = '$eleId'; var DATA_DESTROY_ELE = '$destroyEle'; @@ -6517,8 +6334,8 @@ function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate, $scope.$on('$ionicTabs.leave', onTabsLeave); ionic.Platform.ready(function() { - if ( ionic.Platform.isWebView() && ionic.Platform.isIOS() ) { - self.initSwipeBack(); + if (ionic.Platform.isWebView() && $ionicConfig.views.swipeBackEnabled()) { + self.initSwipeBack(); } }); @@ -6660,7 +6477,6 @@ function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate, if (navViewAttr(viewElement) == VIEW_STATUS_ACTIVE) { viewScope = viewElement.scope(); viewScope && viewScope.$emit(ev.name.replace('Tabs', 'View'), data); - viewScope && viewScope.$broadcast(ev.name.replace('Tabs', 'ParentView'), data); break; } } @@ -6809,8 +6625,7 @@ function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate, var cancelData = {}; function onDragStart(ev) { - if (!isPrimary || !$ionicConfig.views.swipeBackEnabled() || $ionicSideMenuDelegate.isOpenRight() ) return; - + if (!isPrimary) return; startDragX = getDragX(ev); if (startDragX > swipeBackHitWidth) return; @@ -7136,7 +6951,7 @@ IonicModule } function overscroll(val) { - scrollChild.style[ionic.CSS.TRANSFORM] = 'translate3d(0px, ' + val + 'px, 0px)'; + scrollChild.style[ionic.CSS.TRANSFORM] = 'translateY(' + val + 'px)'; lastOverscroll = val; } @@ -7272,17 +7087,13 @@ IonicModule }; function destroy() { - if ( scrollChild ) { - ionic.off(touchStartEvent, handleTouchstart, scrollChild); - ionic.off(touchMoveEvent, handleTouchmove, scrollChild); - ionic.off(touchEndEvent, handleTouchend, scrollChild); - ionic.off('mousedown', handleMousedown, scrollChild); - ionic.off('mousemove', handleTouchmove, scrollChild); - ionic.off('mouseup', handleTouchend, scrollChild); - } - if ( scrollParent ) { - ionic.off('scroll', handleScroll, scrollParent); - } + ionic.off(touchStartEvent, handleTouchstart, scrollChild); + ionic.off(touchMoveEvent, handleTouchmove, scrollChild); + ionic.off(touchEndEvent, handleTouchend, scrollChild); + ionic.off('mousedown', handleMousedown, scrollChild); + ionic.off('mousemove', handleTouchmove, scrollChild); + ionic.off('mouseup', handleTouchend, scrollChild); + ionic.off('scroll', handleScroll, scrollParent); scrollParent = null; scrollChild = null; } @@ -7434,17 +7245,8 @@ function($scope, deregisterInstance(); scrollView && scrollView.__cleanup && scrollView.__cleanup(); angular.element($window).off('resize', resize); - if ( $element ) { - $element.off('scroll', scrollFunc); - } - if ( self._scrollViewOptions ) { - self._scrollViewOptions.el = null; - } - if ( scrollViewOptions ) { - scrollViewOptions.el = null; - } - - scrollView = self.scrollView = scrollViewOptions = self._scrollViewOptions = element = self.$element = $element = null; + $element.off('scroll', scrollFunc); + scrollView = self.scrollView = scrollViewOptions = self._scrollViewOptions = scrollViewOptions.el = self._scrollViewOptions.el = $element = self.$element = element = null; }); $timeout(function() { @@ -7772,15 +7574,20 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io self.content.setTranslateX(amount); - leftShowing = amount > 0; - rightShowing = amount < 0; + if (amount >= 0) { + leftShowing = true; + rightShowing = false; - if (amount > 0) { - // Push the z-index of the right menu down - self.right && self.right.pushDown && self.right.pushDown(); - // Bring the z-index of the left menu up - self.left && self.left.bringUp && self.left.bringUp(); + if (amount > 0) { + // Push the z-index of the right menu down + self.right && self.right.pushDown && self.right.pushDown(); + // Bring the z-index of the left menu up + self.left && self.left.bringUp && self.left.bringUp(); + } } else { + rightShowing = true; + leftShowing = false; + // Bring the z-index of the right menu up self.right && self.right.bringUp && self.right.bringUp(); // Push the z-index of the left menu down @@ -8349,8 +8156,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io var animations = { android: function(ele) { - // Note that this is called as a function, not a constructor. - var self = {}; + var self = this; this.stop = false; @@ -8586,8 +8392,6 @@ function($scope, $element, $ionicHistory) { uiSref: tab.uiSref }); } - - $scope.$broadcast("tabSelected", { selectedTab: tab, selectedTabIndex: tabIndex}); } }; @@ -10071,17 +9875,13 @@ IonicModule.directive('exposeAsideWhen', ['$window', function($window) { require: '^ionSideMenus', link: function($scope, $element, $attr, sideMenuCtrl) { - var prevInnerWidth = $window.innerWidth; - var prevInnerHeight = $window.innerHeight; - - ionic.on('resize', function() { - if (prevInnerWidth === $window.innerWidth && prevInnerHeight === $window.innerHeight) { - return; - } - prevInnerWidth = $window.innerWidth; - prevInnerHeight = $window.innerHeight; + // Setup a match media query listener that triggers a ui change only when a change + // in media matching status occurs + var mq = $attr.exposeAsideWhen == 'large' ? '(min-width:768px)' : $attr.exposeAsideWhen; + var mql = $window.matchMedia(mq); + mql.addListener(function() { onResize(); - }, $window); + }); function checkAsideExpose() { var mq = $attr.exposeAsideWhen == 'large' ? '(min-width:768px)' : $attr.exposeAsideWhen; @@ -10443,7 +10243,7 @@ IonicModule * <button class="button">Right Button</button> * </div> * </ion-header-bar> - * <ion-content class="has-header"> + * <ion-content> * Some content! * </ion-content> * ``` @@ -10470,7 +10270,7 @@ IonicModule * * @usage * ```html - * <ion-content class="has-footer"> + * <ion-content> * Some content! * </ion-content> * <ion-footer-bar align-title="left" class="bar-assertive"> @@ -10608,7 +10408,7 @@ function headerFooterBarDirective(isHeader) { * reach to trigger the on-infinite expression. Default: 1%. * @param {string=} spinner The {@link ionic.directive:ionSpinner} to show while loading. The SVG * {@link ionic.directive:ionSpinner} is now the default, replacing rotating font icons. - * @param {string=} icon The icon to show while loading. Default: 'ion-load-d'. This is depreciated + * @param {string=} icon The icon to show while loading. Default: 'ion-load-d'. This is depreicated * in favor of the SVG {@link ionic.directive:ionSpinner}. * @param {boolean=} immediate-check Whether to check the infinite scroll bounds immediately on load. * @@ -10710,7 +10510,7 @@ IonicModule * <ion-list> * <ion-input> * <input type="text" placeholder="First Name"> -* </ion-input> +* <ion-input> * * <ion-input> * <ion-label>Username</ion-label> @@ -11066,9 +10866,9 @@ IonicModule.directive('ionOptionButton', [function() { return function($scope, $element, $attr, itemCtrl) { if (!itemCtrl.optionsContainer) { itemCtrl.optionsContainer = jqLite(ITEM_TPL_OPTION_BUTTONS); - itemCtrl.$element.prepend(itemCtrl.optionsContainer); + itemCtrl.$element.append(itemCtrl.optionsContainer); } - itemCtrl.optionsContainer.prepend($element); + itemCtrl.optionsContainer.append($element); itemCtrl.$element.addClass('item-right-editable'); @@ -11778,6 +11578,7 @@ IonicModule * @param {boolean=} no-tap-scroll By default, the navbar will scroll the content * to the top when tapped. Set no-tap-scroll to true to disable this behavior. * + * </table><br/> */ IonicModule .directive('ionNavBar', function() { @@ -12152,9 +11953,6 @@ IonicModule * <iframe width="560" height="315" src="//www.youtube.com/embed/dqJRoh8MnBo" * frameborder="0" allowfullscreen></iframe> * - * Note: We do not recommend using [resolve](https://github.com/angular-ui/ui-router/wiki#resolve) - * of AngularUI Router. The recommended approach is to execute any logic needed before beginning the state transition. - * * @param {string=} name A view name. The name should be unique amongst the other views in the * same state. You can have views of the same name that live in different states. For more * information, see ui-router's @@ -12451,7 +12249,7 @@ IonicModule * is now the default, replacing rotating font icons. Set to `none` to disable both the * spinner and the icon. * @param {string=} refreshing-icon The font icon to display after user lets go of the - * refresher. This is deprecated in favor of the SVG {@link ionic.directive:ionSpinner}. + * refresher. This is depreicated in favor of the SVG {@link ionic.directive:ionSpinner}. * @param {boolean=} disable-pulling-rotation Disables the rotation animation of the pulling * icon when it reaches its activated threshold. To be used with a custom `pulling-icon`. * @@ -12496,9 +12294,7 @@ IonicModule $scope.$on('scroll.refreshComplete', function() { $scope.$evalAsync(function() { - if(scrollCtrl.scrollView){ - scrollCtrl.scrollView.finishPullToRefresh(); - } + scrollCtrl.scrollView.finishPullToRefresh(); }); }); } @@ -12540,7 +12336,6 @@ IonicModule * @param {boolean=} paging Whether to scroll with paging. * @param {expression=} on-refresh Called on pull-to-refresh, triggered by an {@link ionic.directive:ionRefresher}. * @param {expression=} on-scroll Called whenever the user scrolls. - * @param {expression=} on-scroll-complete Called whenever the scrolling paging is completed. * @param {boolean=} scrollbar-x Whether to show the horizontal scrollbar. Default true. * @param {boolean=} scrollbar-y Whether to show the vertical scrollbar. Default true. * @param {boolean=} zooming Whether to support pinch-to-zoom @@ -12576,7 +12371,6 @@ function($timeout, $controller, $ionicBind, $ionicConfig) { direction: '@', paging: '@', $onScroll: '&onScroll', - $onScrollComplete: '&onScrollComplete', scroll: '@', scrollbarX: '@', scrollbarY: '@', @@ -12618,8 +12412,7 @@ function($timeout, $controller, $ionicBind, $ionicConfig) { maxZoom: $scope.$eval($scope.maxZoom) || 3, minZoom: $scope.$eval($scope.minZoom) || 0.5, preventDefault: true, - nativeScrolling: nativeScrolling, - scrollingComplete: onScrollComplete + nativeScrolling: nativeScrolling }; if (isPaging) { @@ -12627,17 +12420,10 @@ function($timeout, $controller, $ionicBind, $ionicConfig) { scrollViewOptions.bouncing = false; } - var scrollCtrl = $controller('$ionicScroll', { + $controller('$ionicScroll', { $scope: $scope, scrollViewOptions: scrollViewOptions }); - - function onScrollComplete() { - $scope.$onScrollComplete && $scope.$onScrollComplete({ - scrollTop: scrollCtrl.scrollView.__scrollTop, - scrollLeft: scrollCtrl.scrollView.__scrollLeft - }); - } } } }; @@ -13063,7 +12849,6 @@ IonicModule * @ngdoc directive * @name ionSlideBox * @module ionic - * @codepen AjgEB * @deprecated will be removed in the next Ionic release in favor of the new ion-slides component. * Don't depend on the internal behavior of this widget. * @delegate ionic.service:$ionicSlideBoxDelegate @@ -13071,6 +12856,7 @@ IonicModule * @description * The Slide Box is a multi-page container where each page can be swiped or dragged between: * + *  * * @usage * ```html @@ -13219,7 +13005,7 @@ function($animate, $timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $i link: function($scope, $element, $attr) { // Disable ngAnimate for slidebox and its children - $animate.enabled($element, false); + $animate.enabled(false, $element); // if showPager is undefined, show the pager if (!isDefined($attr.showPager)) { @@ -13296,6 +13082,7 @@ function($animate, $timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $i * @ngdoc directive * @name ionSlides * @module ionic + * @delegate ionic.service:$ionicSlideBoxDelegate * @restrict E * @description * The Slides component is a powerful multi-page container where each page can be swiped or dragged between. @@ -13307,84 +13094,22 @@ function($animate, $timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $i * * @usage * ```html - * <ion-content scroll="false"> - * <ion-slides options="options" slider="data.slider"> - * <ion-slide-page> - * <div class="box blue"><h1>BLUE</h1></div> - * </ion-slide-page> - * <ion-slide-page> - * <div class="box yellow"><h1>YELLOW</h1></div> - * </ion-slide-page> - * <ion-slide-page> - * <div class="box pink"><h1>PINK</h1></div> - * </ion-slide-page> - * </ion-slides> - * </ion-content> - * ``` - * - * ```js - * $scope.options = { - * loop: false, - * effect: 'fade', - * speed: 500, - * } - * - * $scope.$on("$ionicSlides.sliderInitialized", function(event, data){ - * // data.slider is the instance of Swiper - * $scope.slider = data.slider; - * }); - * - * $scope.$on("$ionicSlides.slideChangeStart", function(event, data){ - * console.log('Slide change is beginning'); - * }); - * - * $scope.$on("$ionicSlides.slideChangeEnd", function(event, data){ - * // note: the indexes are 0-based - * $scope.activeIndex = data.slider.activeIndex; - * $scope.previousIndex = data.slider.previousIndex; - * }); - * - * ``` - * - * ## Slide Events - * - * The slides component dispatches events when the active slide changes - * - * <table class="table"> - * <tr> - * <td><code>$ionicSlides.slideChangeStart</code></td> - * <td>This event is emitted when a slide change begins</td> - * </tr> - * <tr> - * <td><code>$ionicSlides.slideChangeEnd</code></td> - * <td>This event is emitted when a slide change completes</td> - * </tr> - * <tr> - * <td><code>$ionicSlides.sliderInitialized</code></td> - * <td>This event is emitted when the slider is initialized. It provides access to an instance of the slider.</td> - * </tr> - * </table> - * - * - * ## Updating Slides Dynamically - * When applying data to the slider at runtime, typically everything will work as expected. - * - * In the event that the slides are looped, use the `updateLoop` method on the slider to ensure the slides update correctly. - * - * ``` - * $scope.$on("$ionicSlides.sliderInitialized", function(event, data){ - * // grab an instance of the slider - * $scope.slider = data.slider; - * }); - * - * function dataChangeHandler(){ - * // call this function when data changes, such as an HTTP request, etc - * if ( $scope.slider ){ - * $scope.slider.updateLoop(); - * } - * } + * <ion-slides on-slide-changed="slideHasChanged($index)"> + * <ion-slide-page> + * <div class="box blue"><h1>BLUE</h1></div> + * </ion-slide-page> + * <ion-slide-page> + * <div class="box yellow"><h1>YELLOW</h1></div> + * </ion-slide-page> + * <ion-slide-page> + * <div class="box pink"><h1>PINK</h1></div> + * </ion-slide-page> + * </ion-slides> * ``` * + * @param {string=} delegate-handle The handle used to identify this slideBox + * with {@link ionic.service:$ionicSlideBoxDelegate}. + * @param {object=} options to pass to the widget. See the full ist here: [http://www.idangero.us/swiper/api/](http://www.idangero.us/swiper/api/) */ IonicModule .directive('ionSlides', [ @@ -13418,17 +13143,10 @@ function($animate, $timeout, $compile) { _this.__slider.createLoop(); } - var slidesLength = _this.__slider.slides.length; - // Don't allow pager to show with > 10 slides - if (slidesLength > 10) { + if (_this.__slider.slides.length > 10) { $scope.showPager = false; } - - // When slide index is greater than total then slide to last index - if (_this.__slider.activeIndex > slidesLength - 1) { - _this.__slider.slideTo(slidesLength - 1); - } }); }; @@ -13443,7 +13161,7 @@ function($animate, $timeout, $compile) { var options = $scope.options || {}; var newOptions = angular.extend({ - pagination: $element.children().children()[1], + pagination: '.swiper-pagination', paginationClickable: true, lazyLoading: true, preloadImages: false @@ -13454,24 +13172,17 @@ function($animate, $timeout, $compile) { $timeout(function() { var slider = new ionic.views.Swiper($element.children()[0], newOptions, $scope, $compile); - $scope.$emit("$ionicSlides.sliderInitialized", { slider: slider }); - _this.__slider = slider; $scope.slider = _this.__slider; $scope.$on('$destroy', function() { slider.destroy(); - _this.__slider = null; }); }); - $timeout(function() { - // if it's a loop, render the slides again just incase - _this.rapidUpdate(); - }, 200); - }], + link: function($scope) { $scope.showPager = true; // Disable ngAnimate for slidebox and its children @@ -13488,10 +13199,6 @@ function($animate, $timeout, $compile) { template: '<div class="swiper-slide" ng-transclude></div>', link: function($scope, $element, $attr, ionSlidesCtrl) { ionSlidesCtrl.rapidUpdate(); - - $scope.$on('$destroy', function() { - ionSlidesCtrl.rapidUpdate(); - }); } }; }]); @@ -13906,10 +13613,11 @@ IonicModule replace: true, require: ['^ionTabs', '^ionTab'], template: - '<a ng-class="{\'has-badge\':badge, \'tab-hidden\':isHidden(), \'tab-item-active\': isTabActive()}" ' + + '<a ng-class="{\'tab-item-active\': isTabActive(), \'has-badge\':badge, \'tab-hidden\':isHidden()}" ' + ' ng-disabled="disabled()" class="tab-item">' + '<span class="badge {{badgeStyle}}" ng-if="badge">{{badge}}</span>' + - '<i class="icon {{getIcon()}}" ng-if="getIcon()"></i>' + + '<i class="icon {{getIconOn()}}" ng-if="getIconOn() && isTabActive()"></i>' + + '<i class="icon {{getIconOff()}}" ng-if="getIconOff() && !isTabActive()"></i>' + '<span class="tab-title" ng-bind-html="title"></span>' + '</a>', scope: { @@ -13957,17 +13665,6 @@ IonicModule $scope.isTabActive = function() { return tabsCtrl.selectedTab() === tabCtrl.$scope; }; - - $scope.getIcon = function() { - if ( tabsCtrl.selectedTab() === tabCtrl.$scope ) { - // active - return $scope.iconOn || $scope.icon; - } - else { - // inactive - return $scope.iconOff || $scope.icon; - } - }; } }; }]); @@ -14266,10 +13963,6 @@ function($timeout, $ionicConfig) { * show. Also contained is transition data, such as the transition type and * direction that will be or was used. * - * Life cycle events are emitted upwards from the transitioning view's scope. In some cases, it is - * desirable for a child/nested view to be notified of the event. - * For this use case, `$ionicParentView` life cycle events are broadcast downwards. - * * <table class="table"> * <tr> * <td><code>$ionicView.loaded</code></td> @@ -14310,56 +14003,8 @@ function($timeout, $ionicConfig) { * <td>The view's controller has been destroyed and its element has been * removed from the DOM.</td> * </tr> - * <tr> - * <td><code>$ionicParentView.enter</code></td> - * <td>The parent view has fully entered and is now the active view. - * This event will fire, whether it was the first load or a cached view.</td> - * </tr> - * <tr> - * <td><code>$ionicParentView.leave</code></td> - * <td>The parent view has finished leaving and is no longer the - * active view. This event will fire, whether it is cached or destroyed.</td> - * </tr> - * <tr> - * <td><code>$ionicParentView.beforeEnter</code></td> - * <td>The parent view is about to enter and become the active view.</td> - * </tr> - * <tr> - * <td><code>$ionicParentView.beforeLeave</code></td> - * <td>The parent view is about to leave and no longer be the active view.</td> - * </tr> - * <tr> - * <td><code>$ionicParentView.afterEnter</code></td> - * <td>The parent view has fully entered and is now the active view.</td> - * </tr> - * <tr> - * <td><code>$ionicParentView.afterLeave</code></td> - * <td>The parent view has finished leaving and is no longer the active view.</td> - * </tr> * </table> * - * ## LifeCycle Event Usage - * - * Below is an example of how to listen to life cycle events and - * access state parameter data - * - * ```js - * $scope.$on("$ionicView.beforeEnter", function(event, data){ - * // handle event - * console.log("State Params: ", data.stateParams); - * }); - * - * $scope.$on("$ionicView.enter", function(event, data){ - * // handle event - * console.log("State Params: ", data.stateParams); - * }); - * - * $scope.$on("$ionicView.afterEnter", function(event, data){ - * // handle event - * console.log("State Params: ", data.stateParams); - * }); - * ``` - * * ## Caching * * Caching can be disabled and enabled in multiple ways. By default, Ionic will |
