/**
* Popr 2.0.0
* Copyright (c) 2015 Tipue
* popr is released under the MIT License
* http://www.tipue.com/popr
* https://github.com/foo123/Popr2
**/
!function(t){"use strict";function o(){var t="CSS1Compat"==document.compatMode;return{l:window.pageXOffset||(t?document.documentElement.scrollLeft:document.body.scrollLeft),t:window.pageYOffset||(t?document.documentElement.scrollTop:document.body.scrollTop),w:window.innerWidth||(t?document.documentElement.clientWidth:document.body.clientWidth),h:window.innerHeight||(t?document.documentElement.clientHeight:document.body.clientHeight)}}function e(t){var o=document.body,e=window,n=o.clientTop||0,p=o.clientLeft||0,r=e.pageYOffset||o.scrollTop,i=e.pageXOffset||o.scrollLeft,c=t.getBoundingClientRect(),a=c.top+r-n,s=c.left+i-p;return{top:a,left:s,width:t.offsetWidth,height:t.offsetHeight}}function n(t,n){var p=t.children(".popr_content")[0],r=e(n),i=o(),c=p.scrollWidth>p.clientWidth?p.offsetWidth-p.clientWidth:0,a=t[0].offsetWidth-c,s=t[0].offsetHeight,l=r.top+r.height,d=r.left+(r.width-a)/2;return t.removeClass("popr_container_left popr_container_right"),(t.hasClass("popr_container_top")||l+s>i.t+i.h)&&(l-=r.height+s,t.hasClass("popr_container_bottom")&&t.removeClass("popr_container_bottom").addClass("popr_container_top")),d<i.l?(d=r.left+r.width,t.addClass("popr_container_right")):d+a>i.l+i.w&&(d=r.left-a,t.addClass("popr_container_left")),t.css({left:d+"px",top:l+"px"})}var p=!1,r=!1;t.fn.popr2=function(o){var e,i,c=t.extend({selector:".popr",content:null,attribute:"data-popr",activate:"click","class":"",mode:"bottom"},o||{});c.selector=c.selector||".popr",c.activate=c.activate||"click",c.attribute=c.attribute||"data-popr","mouseup"===c.activate?(i=c.activate+".popr2box",e=c.activate):(i=c.activate+".popr2box mouseup.popr2box",e=c.activate),t(this).off(i).on(i,c.selector,function(o){if(o.stopPropagation(),e!==o.type)return!1;var r,i,a,s,l=this,d=t(l),u="";t(".popr_container").remove(),s=c.mode,(a=d.attr("data-popr-mode"))&&(s=a),u=d.attr("data-popr-class"),i="popr_container popr_container_"+s+(c["class"]?" "+c["class"]:"")+(u?" "+u:""),r=c.content?"function"==typeof c.content?c.content(l):c.content:t("#"+d.attr(c.attribute)).html();var f=t('<div class="'+i+'"><div class="popr_content">'+r+"</div></div>").appendTo("body");f[0]._popr_target=l,n(f,l),p||(t("body").on("mouseup.popr2 keyup.popr2",function(o){var e=t(o.target);("keyup"===o.type&&27===o.which||"mouseup"===o.type&&(e.is("a,label,button,.popr-item")&&e.parent(".popr_content").length||!e.closest(".popr_container").length))&&(t("body").off("mouseup.popr2 keyup.popr2"),p=!1,setTimeout(function(){t(".popr_container").remove()},10))}),p=!0),f.addClass("popr_visible")}),r||(t(window).off("resize.popr2").on("resize.popr2",function(o){setTimeout(function(){t(".popr_container").each(function(){n(t(this),this._popr_target)})},10)}),r=!0)}}(jQuery);
|