Razique Mahroua
2019-11-28 1759c24ad2d2b35ec5c756e3dd3a60185fe944b7
1
2
3
4
5
6
7
8
/**
 * angular-strap
 * @version v2.0.3 - 2014-05-30
 * @link http://mgcrea.github.io/angular-strap
 * @author Olivier Louvignes (olivier@mg-crea.com)
 * @license MIT License, http://www.opensource.org/licenses/MIT
 */
"use strict";angular.module("mgcrea.ngStrap.tooltip",["mgcrea.ngStrap.helpers.dimensions"]).provider("$tooltip",function(){var e=this.defaults={animation:"am-fade",prefixClass:"tooltip",prefixEvent:"tooltip",container:!1,target:!1,placement:"top",template:"tooltip/tooltip.tpl.html",contentTemplate:!1,trigger:"hover focus",keyboard:!1,html:!1,show:!1,title:"",type:"",delay:0};this.$get=["$window","$rootScope","$compile","$q","$templateCache","$http","$animate","dimensions","$$rAF",function(t,o,n,i,a,r,l,s,u){function c(t,i){function a(){return"body"===m.container?s.offset(m.target||t[0]):s.position(m.target||t[0])}function r(e,t,o,n){var i,a=e.split("-");switch(a[0]){case"right":i={top:t.top+t.height/2-n/2,left:t.left+t.width};break;case"bottom":i={top:t.top+t.height,left:t.left+t.width/2-o/2};break;case"left":i={top:t.top+t.height/2-n/2,left:t.left-o};break;default:i={top:t.top-n,left:t.left+t.width/2-o/2}}if(!a[1])return i;if("top"===a[0]||"bottom"===a[0])switch(a[1]){case"left":i.left=t.left;break;case"right":i.left=t.left+t.width-o}else if("left"===a[0]||"right"===a[0])switch(a[1]){case"top":i.top=t.top-n;break;case"bottom":i.top=t.top+t.height}return i}var c={},$=t[0].nodeName.toLowerCase(),m=c.$options=angular.extend({},e,i);c.$promise=f(m.template);var v=c.$scope=m.scope&&m.scope.$new()||o.$new();m.delay&&angular.isString(m.delay)&&(m.delay=parseFloat(m.delay)),m.title&&(c.$scope.title=m.title),v.$hide=function(){v.$$postDigest(function(){c.hide()})},v.$show=function(){v.$$postDigest(function(){c.show()})},v.$toggle=function(){v.$$postDigest(function(){c.toggle()})},c.$isShown=v.$isShown=!1;var y,w;m.contentTemplate&&(c.$promise=c.$promise.then(function(e){var t=angular.element(e);return f(m.contentTemplate).then(function(e){var o=p('[ng-bind="content"]',t[0]);return o.length||(o=p('[ng-bind="title"]',t[0])),o.removeAttr("ng-bind").html(e),t[0].outerHTML})}));var b,k,S,T;return c.$promise.then(function(e){angular.isObject(e)&&(e=e.data),m.html&&(e=e.replace(g,'ng-bind-html="')),e=h.apply(e),S=e,b=n(e),c.init()}),c.init=function(){m.delay&&angular.isNumber(m.delay)&&(m.delay={show:m.delay,hide:m.delay}),"self"===m.container?T=t:m.container&&(T=p(m.container));var e=m.trigger.split(" ");angular.forEach(e,function(e){"click"===e?t.on("click",c.toggle):"manual"!==e&&(t.on("hover"===e?"mouseenter":"focus",c.enter),t.on("hover"===e?"mouseleave":"blur",c.leave),"button"===$&&"hover"!==e&&t.on(d?"touchstart":"mousedown",c.$onFocusElementMouseDown))}),m.target&&(m.target=angular.isElement(m.target)?m.target:p(m.target)[0]),m.show&&v.$$postDigest(function(){"focus"===m.trigger?t[0].focus():c.show()})},c.destroy=function(){for(var e=m.trigger.split(" "),o=e.length;o--;){var n=e[o];"click"===n?t.off("click",c.toggle):"manual"!==n&&(t.off("hover"===n?"mouseenter":"focus",c.enter),t.off("hover"===n?"mouseleave":"blur",c.leave),"button"===$&&"hover"!==n&&t.off(d?"touchstart":"mousedown",c.$onFocusElementMouseDown))}k&&(k.remove(),k=null),clearTimeout(y),v.$destroy()},c.enter=function(){return clearTimeout(y),w="in",m.delay&&m.delay.show?void(y=setTimeout(function(){"in"===w&&c.show()},m.delay.show)):c.show()},c.show=function(){v.$emit(m.prefixEvent+".show.before",c);var e=m.container?T:null,o=m.container?null:t;k&&k.remove(),k=c.$element=b(v,function(){}),k.css({top:"-9999px",left:"-9999px",display:"block"}).addClass(m.placement),m.animation&&k.addClass(m.animation),m.type&&k.addClass(m.prefixClass+"-"+m.type),l.enter(k,e,o,function(){v.$emit(m.prefixEvent+".show",c)}),c.$isShown=v.$isShown=!0,v.$$phase||v.$root&&v.$root.$$phase||v.$digest(),u(c.$applyPlacement),m.keyboard&&("focus"!==m.trigger?(c.focus(),k.on("keyup",c.$onKeyUp)):t.on("keyup",c.$onFocusKeyUp))},c.leave=function(){return clearTimeout(y),w="out",m.delay&&m.delay.hide?void(y=setTimeout(function(){"out"===w&&c.hide()},m.delay.hide)):c.hide()},c.hide=function(e){return c.$isShown?(v.$emit(m.prefixEvent+".hide.before",c),l.leave(k,function(){v.$emit(m.prefixEvent+".hide",c)}),c.$isShown=v.$isShown=!1,v.$$phase||v.$root&&v.$root.$$phase||v.$digest(),m.keyboard&&null!==k&&k.off("keyup",c.$onKeyUp),e&&"focus"===m.trigger?t[0].blur():void 0):void 0},c.toggle=function(){c.$isShown?c.leave():c.enter()},c.focus=function(){k[0].focus()},c.$applyPlacement=function(){if(k){var e=a(),t=k.prop("offsetWidth"),o=k.prop("offsetHeight"),n=r(m.placement,e,t,o);n.top+="px",n.left+="px",k.css(n)}},c.$onKeyUp=function(e){27===e.which&&c.hide()},c.$onFocusKeyUp=function(e){27===e.which&&t[0].blur()},c.$onFocusElementMouseDown=function(e){e.preventDefault(),e.stopPropagation(),c.$isShown?t[0].blur():t[0].focus()},c}function p(e,t){return angular.element((t||document).querySelectorAll(e))}function f(e){return i.when(a.get(e)||r.get(e)).then(function(t){return angular.isObject(t)?(a.put(e,t.data),t.data):t})}var h=String.prototype.trim,d="createTouch"in t.document,g=/ng-bind="/gi;return c}]}).directive("bsTooltip",["$window","$location","$sce","$tooltip","$$rAF",function(e,t,o,n,i){return{restrict:"EAC",scope:!0,link:function(e,t,a){var r={scope:e};angular.forEach(["template","contentTemplate","placement","container","target","delay","trigger","keyboard","html","animation","type"],function(e){angular.isDefined(a[e])&&(r[e]=a[e])}),angular.forEach(["title"],function(t){a[t]&&a.$observe(t,function(n,a){e[t]=o.trustAsHtml(n),angular.isDefined(a)&&i(function(){l&&l.$applyPlacement()})})}),a.bsTooltip&&e.$watch(a.bsTooltip,function(t,o){angular.isObject(t)?angular.extend(e,t):e.title=t,angular.isDefined(o)&&i(function(){l&&l.$applyPlacement()})},!0);var l=n(t,r);e.$on("$destroy",function(){l.destroy(),r=null,l=null})}}}]);