Skip to content

Instantly share code, notes, and snippets.

@fxck
Last active December 25, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fxck/7028338 to your computer and use it in GitHub Desktop.
Save fxck/7028338 to your computer and use it in GitHub Desktop.
ui-bootstraps modal's backdrop windowClass
index 898b8a7..a2dd010 100644 (file)
--- a/www/public/js/lib/ui/ui-bootstrap.js
+++ b/www/public/js/lib/ui/ui-bootstrap.js
@@ -147,6 +147,8 @@ angular.module('ui.bootstrap.modal', [])
replace: true,\r
templateUrl: 'template/modal/backdrop.html',\r
link: function (scope, element, attrs) {\r
+ scope.windowClass = attrs.windowClass || '';\r
+\r
//trigger CSS transitions\r
$timeout(function () {\r
scope.animate = true;\r
@@ -211,7 +213,7 @@ angular.module('ui.bootstrap.modal', [])
$rootScope.$watch(backdropIndex, function(newBackdropIndex){\r
backdropScope.index = newBackdropIndex;\r
});\r
-\r
+ \r
function removeModalWindow(modalInstance) {\r
\r
var modalWindow = openedWindows.get(modalInstance).value;\r
@@ -223,6 +225,8 @@ angular.module('ui.bootstrap.modal', [])
modalWindow.modalDomEl.remove();\r
\r
//remove backdrop if no longer needed\r
+ //var backdropIndex = backdropIndex();\r
+\r
if (backdropIndex() == -1) {\r
backdropDomEl.remove();\r
backdropDomEl = undefined;\r
@@ -230,6 +234,12 @@ angular.module('ui.bootstrap.modal', [])
\r
//destroy scope\r
modalWindow.modalScope.$destroy();\r
+ \r
+ if (backdropIndex() != -1) {\r
+ var modal = openedWindows.top();\r
+ backdropScope.windowClass = modal.value.windowClass;\r
+ }\r
+ \r
}\r
\r
$document.bind('keydown', function (evt) {\r
@@ -251,7 +261,8 @@ angular.module('ui.bootstrap.modal', [])
deferred: modal.deferred,\r
modalScope: modal.scope,\r
backdrop: modal.backdrop,\r
- keyboard: modal.keyboard\r
+ keyboard: modal.keyboard,\r
+ windowClass: modal.windowClass\r
});\r
\r
var angularDomEl = angular.element('<div modal-window></div>');\r
@@ -263,10 +274,13 @@ angular.module('ui.bootstrap.modal', [])
openedWindows.top().value.modalDomEl = modalDomEl;\r
body.append(modalDomEl);\r
\r
+ backdropjqLiteEl = angular.element('<div modal-backdrop></div>');\r
if (backdropIndex() >= 0 && !backdropDomEl) {\r
- backdropjqLiteEl = angular.element('<div modal-backdrop></div>');\r
+ backdropjqLiteEl.attr('window-class', modal.windowClass);\r
backdropDomEl = $compile(backdropjqLiteEl)(backdropScope);\r
body.append(backdropDomEl);\r
+ } else {\r
+ backdropScope.windowClass = modal.windowClass;\r
}\r
};\r
\r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment