forked from mgcrea/angular-strap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodal.min.js
More file actions
9 lines (9 loc) · 4.58 KB
/
Copy pathmodal.min.js
File metadata and controls
9 lines (9 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
/**
* angular-strap
* @version v2.3.6 - 2015-11-14
* @link http://mgcrea.github.io/angular-strap
* @author Olivier Louvignes <olivier@mg-crea.com> (https://github.com/mgcrea)
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
'use strict';angular.module('mgcrea.ngStrap.modal',['mgcrea.ngStrap.core','mgcrea.ngStrap.helpers.dimensions']).provider('$modal',function(){var n=this.defaults={animation:'am-fade',backdropAnimation:'am-fade',prefixClass:'modal',prefixEvent:'modal',placement:'top',templateUrl:'modal/modal.tpl.html',template:'',contentTemplate:!1,container:!1,element:null,backdrop:!0,keyboard:!0,html:!1,show:!0};this.$get=['$window','$rootScope','$bsCompiler','$animate','$timeout','$sce','dimensions',function(e,t,o,i,a,r,l){function s(e){function a(){E.$emit(C.prefixEvent+'.show',y)}function l(){E.$emit(C.prefixEvent+'.hide',y),p.removeClass(C.prefixClass+'-open'),C.animation&&p.removeClass(C.prefixClass+'-with-'+C.animation)}function s(){C.backdrop&&(D.on('click',v),T.on('click',v),T.on('wheel',k))}function g(){C.backdrop&&(D.off('click',v),T.off('click',v),T.off('wheel',k))}function w(){C.keyboard&&D.on('keyup',y.$onKeyUp)}function b(){C.keyboard&&D.off('keyup',y.$onKeyUp)}function v(n){n.target===n.currentTarget&&('static'===C.backdrop?y.focus():y.hide())}function k(n){n.preventDefault()}function x(){y.$isShown&&null!==D&&(g(),b()),U&&(U.$destroy(),U=null),D&&(D.remove(),D=y.$element=null)}var y={},C=y.$options=angular.extend({},n,e),S=y.$promise=o.compile(C),E=y.$scope=C.scope&&C.scope.$new()||t.$new();C.element||C.container||(C.container='body'),y.$id=C.id||C.element&&C.element.attr('id')||'',d(['title','content'],function(n){C[n]&&(E[n]=r.trustAsHtml(C[n]))}),E.$hide=function(){E.$$postDigest(function(){y.hide()})},E.$show=function(){E.$$postDigest(function(){y.show()})},E.$toggle=function(){E.$$postDigest(function(){y.toggle()})},y.$isShown=E.$isShown=!1;var A,D,U,T=angular.element('<div class="'+C.prefixClass+'-backdrop"/>');return T.css({position:'fixed',top:'0px',left:'0px',bottom:'0px',right:'0px'}),S.then(function(n){A=n,y.init()}),y.init=function(){C.show&&E.$$postDigest(function(){y.show()})},y.destroy=function(){x(),T&&(T.remove(),T=null),E.$destroy()},y.show=function(){if(!y.$isShown){var n,e;if(angular.isElement(C.container)?(n=C.container,e=C.container[0].lastChild?angular.element(C.container[0].lastChild):null):C.container?(n=u(C.container),e=n[0]&&n[0].lastChild?angular.element(n[0].lastChild):null):(n=null,e=C.element),D&&x(),U=y.$scope.$new(),D=y.$element=A.link(U,function(n,e){}),C.backdrop&&(D.css({'z-index':$+20*m}),T.css({'z-index':h+20*m}),m++),!E.$emit(C.prefixEvent+'.show.before',y).defaultPrevented){D.css({display:'block'}).addClass(C.placement),C.animation&&(C.backdrop&&T.addClass(C.backdropAnimation),D.addClass(C.animation)),C.backdrop&&i.enter(T,p,null),angular.version.minor<=2?i.enter(D,n,e,a):i.enter(D,n,e).then(a),y.$isShown=E.$isShown=!0,c(E);var t=D[0];f(function(){t.focus()}),p.addClass(C.prefixClass+'-open'),C.animation&&p.addClass(C.prefixClass+'-with-'+C.animation),s(),w()}}},y.hide=function(){y.$isShown&&(C.backdrop&&m--,E.$emit(C.prefixEvent+'.hide.before',y).defaultPrevented||(angular.version.minor<=2?i.leave(D,l):i.leave(D).then(l),C.backdrop&&i.leave(T),y.$isShown=E.$isShown=!1,c(E),g(),b()))},y.toggle=function(){y.$isShown?y.hide():y.show()},y.focus=function(){D[0].focus()},y.$onKeyUp=function(n){27===n.which&&y.$isShown&&(y.hide(),n.stopPropagation())},y}function c(n){n.$$phase||n.$root&&n.$root.$$phase||n.$digest()}function u(n,e){return angular.element((e||document).querySelectorAll(n))}var d=angular.forEach,f=(String.prototype.trim,e.requestAnimationFrame||e.setTimeout),p=angular.element(e.document.body),m=0,$=1050,h=1040;return s}]}).directive('bsModal',['$window','$sce','$modal',function(n,e,t){return{restrict:'EAC',scope:!0,link:function(n,o,i,a){var r={scope:n,element:o,show:!1};angular.forEach(['template','templateUrl','controller','controllerAs','contentTemplate','placement','backdrop','keyboard','html','container','animation','backdropAnimation','id','prefixEvent','prefixClass'],function(n){angular.isDefined(i[n])&&(r[n]=i[n])});var l=/^(false|0|)$/i;angular.forEach(['backdrop','keyboard','html','container'],function(n){angular.isDefined(i[n])&&l.test(i[n])&&(r[n]=!1)}),angular.forEach(['title','content'],function(t){i[t]&&i.$observe(t,function(o,i){n[t]=e.trustAsHtml(o)})}),i.bsModal&&n.$watch(i.bsModal,function(e,t){angular.isObject(e)?angular.extend(n,e):n.content=e},!0);var s=t(r);o.on(i.trigger||'click',s.toggle),n.$on('$destroy',function(){s&&s.destroy(),r=null,s=null})}}}]);
//# sourceMappingURL=modal.min.js.map