Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modal): wip compat ng 1.4 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(grunt) {
grunt.util.linefeed = '\n';

grunt.initConfig({
ngversion: '1.3.13',
ngversion: '1.4.1',
bsversion: '3.1.1',
modules: [],//to be filled in by build task
pkg: grunt.file.readJSON('package.json'),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"url": "https://github.com/angular-ui/bootstrap.git"
},
"devDependencies": {
"angular": "<=1.3.x",
"angular-mocks": "<=1.3.x",
"angular": "<=1.4.x",
"angular-mocks": "<=1.4.x",
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
Expand Down
57 changes: 34 additions & 23 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,29 @@ angular.module('ui.bootstrap.modal', [])
/**
* A helper directive for the $modal service. It creates a backdrop element.
*/
.directive('modalBackdrop', ['$timeout', function ($timeout) {
.directive('modalBackdrop', ['$timeout', '$animate', function ($timeout, $animate) {
return {
restrict: 'EA',
replace: true,
templateUrl: 'template/modal/backdrop.html',
compile: function (tElement, tAttrs) {
tElement.addClass(tAttrs.backdropClass);
// tElement.addClass(tAttrs.backdropClass);
return linkFn;
}
};

function linkFn(scope, element, attrs) {
scope.animate = false;

//trigger CSS transitions
$timeout(function () {
scope.animate = true;
});
if ($animate.enabled()) {
$animate.on('addClass', element, function(el, phase) {
});
$animate.addClass(element, 'in');
} else {
element.addClass('in');
}
}
}])

.directive('modalWindow', ['$modalStack', '$q', function ($modalStack, $q) {
.directive('modalWindow', ['$modalStack', '$q', '$animate', function ($modalStack, $q, $animate) {
return {
restrict: 'EA',
scope: {
Expand Down Expand Up @@ -120,7 +121,12 @@ angular.module('ui.bootstrap.modal', [])

modalRenderDeferObj.promise.then(function () {
// trigger CSS transitions
scope.animate = true;
// scope.animate = true;
if ($animate.enabled()) {
$animate.addClass(element, 'in');
} else {
element.addClass('in');
}

var inputsWithAutofocus = element[0].querySelectorAll('[autofocus]');
/**
Expand All @@ -147,16 +153,17 @@ angular.module('ui.bootstrap.modal', [])
};
}])

.directive('modalAnimationClass', [
function () {
return {
compile: function (tElement, tAttrs) {
if (tAttrs.modalAnimation) {
tElement.addClass(tAttrs.modalAnimationClass);
}
}
};
}])
//TODO: uncomment and use configurable animate class
// .directive('modalAnimationClass', [
// function () {
// return {
// compile: function (tElement, tAttrs) {
// if (tAttrs.modalAnimation) {
// tElement.addClass(tAttrs.modalAnimationClass);
// }
// }
// };
// }])

.directive('modalTransclude', function () {
return {
Expand Down Expand Up @@ -233,11 +240,15 @@ angular.module('ui.bootstrap.modal', [])
// Closing animation
scope.animate = false;

if (domEl.attr('modal-animation') && $animate.enabled()) {
if (domEl.attr('modal-animation') && $animate.enabled() && domEl.hasClass('in')) {
// transition out
domEl.one('$animate:close', function closeFn() {
$rootScope.$evalAsync(afterAnimating);
$animate.on('removeClass', domEl, function closeFn(el, phase) {
if (phase === 'close') {
$rootScope.$evalAsync(afterAnimating);
}
});

$animate.removeClass(domEl, 'in');
} else {
// Ensure this call is async
$timeout(afterAnimating);
Expand Down
6 changes: 3 additions & 3 deletions template/modal/backdrop.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="modal-backdrop"
modal-animation-class="fade"
ng-class="{in: animate}"
<div class="modal-backdrop fade"
animate-class="fade"
animate="in"
ng-style="{'z-index': 1040 + (index && 1 || 0) + index*10}"
></div>
5 changes: 2 additions & 3 deletions template/modal/window.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div modal-render="{{$isRendered}}" tabindex="-1" role="dialog" class="modal"
modal-animation-class="fade"
ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">
<div modal-render="{{$isRendered}}" tabindex="-1" role="dialog" class="modal fade"
ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">
<div class="modal-dialog" ng-class="size ? 'modal-' + size : ''"><div class="modal-content" modal-transclude></div></div>
</div>