PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
wpforo / assets / js / bootstrap-popover.min.js

bootstrap-popover.min.js in wpForo Forum 3.1.6, at assets/js/bootstrap-popover.min.js

9 lines 9.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*!
2 * @copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021
3 * @version 1.5.1
4 *
5 * Bootstrap Popover Extended - Popover with modal behavior, styling enhancements and more.
6 *
7 * For more JQuery/Bootstrap plugins and demos visit http://plugins.krajee.com
8 * For more Yii related demos visit http://demos.krajee.com
9 */!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof module&&"object"==typeof module.exports?require("jquery"):window.jQuery)}(function(t){"use strict";t.fn.popoverXBsVersion||(t.fn.popoverXBsVersion=window.bootstrap&&window.bootstrap.Modal&&bootstrap.Modal.VERSION||window.Modal&&window.Modal.VERSION||"3.x.x");var o,e,i;o={NAMESPACE:".popoverX",modalOptions:["keyboard","focus","show"],kvLog:function(t){t="bootstrap-popover-x: "+t,window.console&&window.console.log?window.console.log(t):window.alert(t)},addCss:function(t,o){t.removeClass(o).addClass(o)},handler:function(t,e,i){var r=e+o.NAMESPACE;return t.off(r).on(r,i)},raise:function(t,e,i){var r=e+(void 0===i?".target":i)+o.NAMESPACE;return t.trigger(r)},isBs:function(o){var e=t.trim((t.fn.popoverXBsVersion||"")+"");return o=parseInt(o,10),e?o===parseInt(e.charAt(0),10):4===o},getDataAttr:function(t){return"data-"+(o.isBs(5)?"bs-":"")+t}},e=function(o,e){var i=this;i.options=e,i.$element=t(o),i.init()},i=function(o,e){var i=this;i.options=e,i.$element=t(o),i.$dialog=i.$element,i.init()},e.prototype={constructor:e,init:function(){var e,i,r=this,n=r.$element,a=r.options||{},s=n.attr("href"),p=function(t){o.kvLog("PopoverX initialization skipped! "+t)};if(r.href=s,!n||!n.length)return void p("PopoverX triggering button element could not be found.");if(n.attr("data-toggle","popover-x"),a.target?(n.data("target",a.target),i=t(a.target)):i=t(n.data("target")||s&&s.replace(/.*(?=#[^\s]+$)/,"")),!i.length)return void p("PopoverX dialog element could not be found.");if(r.$dialog=i,i.attr(o.getDataAttr("backdrop"),"false"),o.addCss(i,"popover-x"),!i.data("popover-x")){var l=t.extend(!0,{remote:s&&!/#/.test(s)},i.data(),n.data(),a);l.$target=n,i.popoverX(l)}return e=a.trigger,"string"!=typeof e?void p("Invalid or improper configuration for PopoverX trigger."):(e=e.split(" "),void t.each(e,function(t,o){r.listen(o)}))},listen:function(t){var e,i,r=this,n=r.$element,a=r.$dialog,s=!1,p=r.href;"manual"!==t&&("click"!==t&&"keyup"!==t&&(s=!0),s?(e="hover"===t?"mouseenter":"focusin",i="hover"===t?"mouseleave":"focusout",o.handler(n,e,function(){o.raise(a,e).popoverX("show")}),o.handler(n,i,function(){o.raise(a,i).popoverX("hide")})):o.handler(n,t,function(e){return"keyup"===t?void(a&&27===e.which&&o.raise(a,t).popoverX("hide")):(p&&"click"===t&&e.preventDefault(),o.raise(a,t).popoverX("toggle"),void o.handler(a,"hide",function(){n.focus()}))}))},destroy:function(){var t=this;t.$element.off(o.NAMESPACE),t.$dialog.modal("dispose").off(o.NAMESPACE)}},i.prototype={constructor:i,init:function(){var e=this,i=e.$element,r=e.options,n=r.$container,a=o.isBs(5);n&&n.length&&(e.$body=n),e.$body&&e.$body.length||(e.$body=t(document.body)),t.each(o.modalOptions,function(t,e){r[e]&&i.attr(o.getDataAttr(e),r[e])}),i.attr(o.getDataAttr("backdrop"),"false"),a&&!i.find(".modal-dialog").length&&(t(document.createElement("div")).addClass("modal-dialog").css({margin:0,"pointer-events":"all"}).insertAfter(i).append(i.contents()).appendTo(i),o.addCss(i.find(".arrow"),"popover-arrow")),o.addCss(i,"is-bs"+t.fn.popoverXBsVersion.charAt(0)),e.bodyPadding=e.$body.css("padding"),e.$target=e.options.$target,e.$marker=t(document.createElement("div")).addClass("popover-x-marker").insertAfter(i).hide(),i.find(".popover-footer").length&&o.addCss(i,"has-footer"),e.options.remote&&i.find(".popover-content").on("load",e.options.remote,function(){i.trigger("load.complete.popoverX")}),i.on("click.dismiss"+o.NAMESPACE,'[data-dismiss="popover-x"]',t.proxy(e.hide,e)),r.closePopoverOnBlur&&t(document).on("click",function(o){var e=t(o.target);e.closest('[data-toggle="popover-x"]').length||(e.closest(".popover-x").length?o.stopPropagation():t(".popover-x:visible").popoverX("hide"))});var s,p="hide.bs.modal.popoverX",l=t(".modal");l.length&&(s=l.find("[data-toggle='popover-x']"),s.length&&l.off(p).on(p,function(){s.each(function(){var o=t(this).data("target")||null,e=t(o);e.length&&e.is(":visible")&&e.popoverX("hide")})})),t(window).resize(function(){var t="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;!t&&i.hasClass("kv-popover-active")&&(e.hide(),setTimeout(function(){e.show(!0)},50))})},getPlacement:function(){var t=this,o=t.getPosition(),e=t.options.placement,i=document.documentElement,r=document.body,n=i.clientWidth,a=i.clientHeight,s=Math.max(r.scrollTop||0,i.scrollTop),p="horizontal"===e,l=Math.max(r.scrollLeft||0,i.scrollLeft),d="vertical"===e,f=Math.max(0,o.left-l),h=Math.max(0,o.top-s),c="auto"===e||p||d,g=window.innerWidth||i||document.body.clientWidth;if(t.options.autoPlaceSmallScreen&&g<t.options.smallScreenWidth&&(c=!0),c)return n/3>f?a/3>h?p?"right right-top":"bottom bottom-left":2*a/3>h?d?a/2>=h?"bottom bottom-left":"top top-left":"right":p?"right right-bottom":"top top-left":2*n/3>f?a/3>h?p?n/2>=f?"right right-top":"left left-top":"bottom":2*a/3>h?p?n/2>=f?"right":"left":a/2>=h?"bottom":"top":p?n/2>=f?"right right-bottom":"left left-bottom":"top":a/3>h?p?"left left-top":"bottom bottom-left":2*a/3>h?d?a/2>=h?"bottom-right":"top-right":"left":p?"left left-bottom":"top top-left";switch(e){case"auto-top":return n/3>f?"top top-left":2*n/3>f?"top":"top top-right";case"auto-bottom":return n/3>f?"bottom bottom-left":2*n/3>f?"bottom":"bottom bottom-right";case"auto-left":return a/3>h?"left left-top":2*a/3>h?"left":"left left-bottom";case"auto-right":return a/3>h?"right right-top":2*a/3>h?"right":"right right-bottom";default:return e}},getPosition:function(){var o=this,e=o.$target,i=e[0].getBoundingClientRect(),r=o.$body,n=r.css("position");if(r.is(document.body)||"static"===n)return t.extend({},e.offset(),{width:e[0].offsetWidth||i.width,height:e[0].offsetHeight||i.height});if("relative"===n)return{top:e.offset().top-r.offset().top,left:e.offset().left-r.offset().left,width:e[0].offsetWidth||i.width,height:e[0].offsetHeight||i.height};var a=r[0].getBoundingClientRect();return{top:i.top-a.top+r.scrollTop(),left:i.left-a.left+r.scrollLeft(),width:i.width,height:i.height}},refreshPosition:function(){var t,e=this,i=e.$element,r=e.getPosition(),n=i[0].offsetWidth,a=i[0].offsetHeight,s=e.getPlacement();switch(s){case"bottom":t={top:r.top+r.height,left:r.left+r.width/2-n/2};break;case"bottom bottom-left":t={top:r.top+r.height,left:r.left};break;case"bottom bottom-right":t={top:r.top+r.height,left:r.left+r.width-n};break;case"top":t={top:r.top-a,left:r.left+r.width/2-n/2};break;case"top top-left":t={top:r.top-a,left:r.left};break;case"top top-right":t={top:r.top-a,left:r.left+r.width-n};break;case"left":t={top:r.top+r.height/2-a/2,left:r.left-n};break;case"left left-top":t={top:r.top,left:r.left-n};break;case"left left-bottom":t={top:r.top+r.height-a,left:r.left-n};break;case"right":t={top:r.top+r.height/2-a/2,left:r.left+r.width};break;case"right right-top":t={top:r.top,left:r.left+r.width};break;case"right right-bottom":t={top:r.top+r.height-a,left:r.left+r.width};break;default:o.kvLog("Invalid popover placement '"+s+"'.")}i.removeClass("bottom top left right bottom-left top-left bottom-right top-right left-bottom left-top right-bottom right-top").css(t).addClass(s+" in")},validateOpenPopovers:function(){var o=this,e=o.$element;o.options.closeOpenPopovers&&o.$body.find(".popover:visible").each(function(){var o=t(this);o.is(e)||o.popoverX("hide")})},hide:function(){var t=this,o=t.$element;t.$body.removeClass("popover-x-body"),o.removeClass("kv-popover-active"),o.modal("hide"),o.insertBefore(t.$marker)},show:function(t){var e=this,i=e.$element;i.addClass("kv-popover-active"),i.css(e.options.dialogCss).appendTo(e.$body),t||e.validateOpenPopovers(),o.addCss(e.$body,"popover-x-body"),i.modal("show"),e.$body.css({padding:e.bodyPadding}),i.css({padding:0}),e.refreshPosition()},toggle:function(){var t=this;t.$element.is(":visible")?t.hide():t.show()},destroy:function(){var t=this;t.$element.modal("dispose").off(o.NAMESPACE)}},t.fn.popoverButton=function(o){var i=this;return i.each(function(){var i=t(this),r=i.data("popover-button"),n=t.extend({},t.fn.popoverButton.defaults,i.data(),"object"==typeof o&&o);r||i.data("popover-button",r=new e(this,n)),"string"==typeof o&&r[o]()})},t.fn.popoverX=function(o){var e=this;return e.each(function(){var e=t(this),r=e.data("popover-x"),n=t.extend({},t.fn.popoverX.defaults,e.data(),"object"==typeof o&&o);n.$target||(r&&r.$target?n.$target=r.$target:n.$target=o.$target||t(o.target)),r||e.data("popover-x",r=new i(this,n)),"string"==typeof o?r[o]():n.show&&r.show(!0)})},t.fn.popoverButton.defaults={trigger:"click keyup"},t.fn.popoverX.defaults=t.extend(!0,{},{placement:"auto",dialogCss:{top:0,left:0,display:"block","z-index":1065},autoPlaceSmallScreen:!0,smallScreenWidth:640,closeOpenPopovers:!0,closePopoverOnBlur:!0,keyboard:!0,focus:!0}),t.fn.popoverButton.Constructor=e,t.fn.popoverX.Constructor=i,t(document).ready(function(){var o=t("[data-toggle='popover-x']");o.length&&o.popoverButton()})});