From 2c23189c87a8e49763f715081168a0c061b6b9c9 Mon Sep 17 00:00:00 2001 From: David Epely Date: Fri, 3 Jul 2015 06:46:22 +0200 Subject: [PATCH] fix(modal): wip compat ng 1.4 --- Gruntfile.js | 2 +- package.json | 4 +-- src/modal/modal.js | 57 +++++++++++++++++++++--------------- template/modal/backdrop.html | 6 ++-- template/modal/window.html | 5 ++-- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 3555901de1..78e94b4cd5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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'), diff --git a/package.json b/package.json index 700ecc406c..e03225f565 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/modal/modal.js b/src/modal/modal.js index c6215f4a11..c37d0b57f1 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -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: { @@ -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]'); /** @@ -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 { @@ -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); diff --git a/template/modal/backdrop.html b/template/modal/backdrop.html index 72514a377d..ccd0bcf6b5 100644 --- a/template/modal/backdrop.html +++ b/template/modal/backdrop.html @@ -1,5 +1,5 @@ - diff --git a/template/modal/window.html b/template/modal/window.html index 5501937bd6..ad04b92abb 100644 --- a/template/modal/window.html +++ b/template/modal/window.html @@ -1,5 +1,4 @@ -