dropdown.min.js 3.0 KB

12345678910
  1. /**
  2. * angular-strap
  3. * @version v2.3.9 - 2016-06-10
  4. * @link http://mgcrea.github.io/angular-strap
  5. * @author Olivier Louvignes <olivier@mg-crea.com> (https://github.com/mgcrea)
  6. * @license MIT License, http://www.opensource.org/licenses/MIT
  7. */
  8. 'use strict';angular.module('mgcrea.ngStrap.dropdown',['mgcrea.ngStrap.tooltip']).provider('$dropdown',function(){var e=this.defaults={animation:'am-fade',prefixClass:'dropdown',prefixEvent:'dropdown',placement:'bottom-left',templateUrl:'dropdown/dropdown.tpl.html',trigger:'click',container:!1,keyboard:!0,html:!1,delay:0};this.$get=['$window','$rootScope','$tooltip','$timeout',function(o,n,t,r){function a(o,a){function d(e){return e.target!==o[0]?e.target!==o[0]&&c.hide():void 0}var c={},s=angular.extend({},e,a);c.$scope=s.scope&&s.scope.$new()||n.$new(),c=t(o,s);var p=o.parent();c.$onKeyDown=function(e){if(/(38|40)/.test(e.keyCode)){e.preventDefault(),e.stopPropagation();var o=angular.element(c.$element[0].querySelectorAll('li:not(.divider) a'));if(o.length){var n;angular.forEach(o,function(e,o){i&&i.call(e,':focus')&&(n=o)}),38===e.keyCode&&n>0?n--:40===e.keyCode&&n<o.length-1?n++:angular.isUndefined(n)&&(n=0),o.eq(n)[0].focus()}}};var u=c.show;c.show=function(){u(),r(function(){s.keyboard&&c.$element&&c.$element.on('keydown',c.$onKeyDown),l.on('click',d)},0,!1),p.hasClass('dropdown')&&p.addClass('open')};var f=c.hide;c.hide=function(){c.$isShown&&(s.keyboard&&c.$element&&c.$element.off('keydown',c.$onKeyDown),l.off('click',d),p.hasClass('dropdown')&&p.removeClass('open'),f())};var m=c.destroy;return c.destroy=function(){l.off('click',d),m()},c}var l=angular.element(o.document.body),i=Element.prototype.matchesSelector||Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector;return a}]}).directive('bsDropdown',['$window','$sce','$dropdown',function(e,o,n){return{restrict:'EAC',scope:!0,compile:function(e,o){if(!o.bsDropdown){for(var t=e[0].nextSibling;t&&1!==t.nodeType;)t=t.nextSibling;t&&t.className.split(' ').indexOf('dropdown-menu')>=0&&(o.template=t.outerHTML,o.templateUrl=void 0,t.parentNode.removeChild(t))}return function(e,t,r){var a={scope:e};angular.forEach(['template','templateUrl','controller','controllerAs','placement','container','delay','trigger','keyboard','html','animation','id','autoClose'],function(e){angular.isDefined(o[e])&&(a[e]=o[e])});var l=/^(false|0|)$/i;angular.forEach(['html','container'],function(e){angular.isDefined(r[e])&&l.test(r[e])&&(a[e]=!1)}),angular.forEach(['onBeforeShow','onShow','onBeforeHide','onHide'],function(o){var n='bs'+o.charAt(0).toUpperCase()+o.slice(1);angular.isDefined(r[n])&&(a[o]=e.$eval(r[n]))}),r.bsDropdown&&e.$watch(r.bsDropdown,function(o,n){e.content=o},!0);var i=n(t,a);r.bsShow&&e.$watch(r.bsShow,function(e,o){i&&angular.isDefined(e)&&(angular.isString(e)&&(e=!!e.match(/true|,?(dropdown),?/i)),e===!0?i.show():i.hide())}),e.$on('$destroy',function(){i&&i.destroy(),a=null,i=null})}}}}]);
  9. //# sourceMappingURL=dropdown.min.js.map