Skip to content

Commit

Permalink
fix(backdrop): Changed z-index for loading backdrop only. Fixes #1428
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed May 22, 2014
1 parent 633821d commit 4c700e9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
11 changes: 10 additions & 1 deletion js/angular/service/backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function($document) {

var el = jqLite('<div class="backdrop">');
var backdropHolds = 0;
var backdropExtraClasses = null;

$document[0].body.appendChild(el[0]);

Expand All @@ -60,13 +61,19 @@ function($document) {
_element: el
};

function retain() {
function retain(extraClasses) {
backdropExtraClasses = extraClasses;

if ( (++backdropHolds) === 1 ) {
el.addClass('visible');
ionic.requestAnimationFrame(function() {
backdropHolds && el.addClass('active');
});
}
if(extraClasses) {
console.log('Adding', extraClasses);
el.addClass(extraClasses);
}
}
function release() {
if ( (--backdropHolds) === 0 ) {
Expand All @@ -75,5 +82,7 @@ function($document) {
!backdropHolds && el.removeClass('visible');
}, 100);
}
el.removeClass(backdropExtraClasses);

This comment has been minimized.

Copy link
@ajoslin

ajoslin May 22, 2014

Contributor

What if extraClasses has changed since the last retain?

$ionicBackdrop.retain('foo')
$ionicBackdrop.retain('bar')
$ionicBackdrop.release(); //foo stays forever

This comment has been minimized.

Copy link
@mlynch

mlynch May 22, 2014

Author Contributor

k I tweaked in bfce8e2

This comment has been minimized.

Copy link
@ajoslin

ajoslin via email May 22, 2014

Contributor
backdropExtraClasses = null;
}
}]);
2 changes: 1 addition & 1 deletion js/angular/service/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function($document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q, $log, $c
//options.showBackdrop: deprecated
this.hasBackdrop = !options.noBackdrop && options.showBackdrop !== false;
if (this.hasBackdrop) {
$ionicBackdrop.retain();
$ionicBackdrop.retain('backdrop-loading');
}
}

Expand Down
6 changes: 3 additions & 3 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ $badge-default-text: #AAAAAA !default;

$z-index-action-sheet: 11 !default;
$z-index-badge: 1 !default;
$z-index-backdrop: 10 !default;
$z-index-backdrop: 11 !default;
$z-index-bar: 10 !default;
$z-index-bar-title: 0 !default;
$z-index-bar-button: 1 !default;
Expand All @@ -663,11 +663,11 @@ $z-index-item-options: 1 !default;
$z-index-item-radio: 3 !default;
$z-index-item-reordering: 9 !default;
$z-index-item-toggle: 3 !default;
$z-index-loading: 11 !default;
$z-index-loading: 13 !default;
$z-index-menu: 0 !default;
$z-index-modal: 10 !default;
$z-index-pane: 1 !default;
$z-index-popup: 11 !default;
$z-index-popup: 12 !default;
$z-index-scroll-bar: 9999 !default;
$z-index-slider-pager: 1 !default;
$z-index-tabs: 5 !default;
Expand Down
8 changes: 8 additions & 0 deletions test/unit/angular/service/loading.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ describe('$ionicLoading service', function() {
expect(loader.element.text()).toBe('1 content');
}));

it('should add and remove backdrop-loading to backdrop', inject(function($ionicLoading, $ionicBackdrop) {
var loader = TestUtil.unwrapPromise($ionicLoading._getLoader());
loader.show({ templateUrl: 'template.html' });
expect($ionicBackdrop._element.hasClass('backdrop-loading')).toBe(true);
loader.hide();
expect($ionicBackdrop._element.hasClass('backdrop-loading')).toBe(false);
}));

});

describe('.hide()', function() {
Expand Down

0 comments on commit 4c700e9

Please sign in to comment.