Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jconfirm

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jconfirm - npm Package Compare versions

Comparing version 4.4.1 to 4.4.2

15

jConfirm.js

@@ -356,2 +356,13 @@ /*

//get tooltip dimensions
let tooltip_width = helper.tooltip.outerWidth();
let tooltip_height = helper.tooltip.outerHeight();
//if the original element is gone
if( helper.dom_wrapped.length === 0 )
{
helper.position = 'auto';
return ['none', 0, tooltip_width, tooltip_height, 'undefined'];
}
//get position + size of clicked element

@@ -369,6 +380,2 @@ let elem_position = helper.dom_wrapped.offset();

//get tooltip dimensions
let tooltip_width = helper.tooltip.outerWidth();
let tooltip_height = helper.tooltip.outerHeight();
//get window dimensions

@@ -375,0 +382,0 @@ let window_width = document.querySelector('body').offsetWidth;

@@ -8,5 +8,5 @@ /*

*/
(function(a){a.fn.jConfirm=function(b){var c=a(this);if(1<this.length)return this.each(function(){a(this).jConfirm(b)}),this;if('undefined'==typeof this||1!==this.length)return this;b=a.extend({},a.jConfirm.defaults,b,c.data()),b.class+=' jc-'+b.theme+'-theme',b.class+=' jc-'+b.size;let d={dom:this,dom_wrapped:c,position_debug:b.position_debug,follow_href:b.follow_href,open_new_tab:b.open_new_tab,hide_on_click:b.hide_on_click,question:b.question,theme:b.theme,class:b.class,backdrop:b.backdrop,btns:b.btns,confirm_text:b.confirm_text,deny_text:b.deny_text,show_deny_btn:b.show_deny_btn,position:b.position,show_now:b.show_now,dataAttr:'jConfirm',createTooltipHTML:function(){d.btns||(d.btns=[{text:d.confirm_text,class:-1<d.theme.indexOf('bootstrap')?'btn btn-success':'jc-button-highlight',event:'confirm'}],d.show_deny_btn&&d.btns.push({text:d.deny_text,class:-1<d.theme.indexOf('bootstrap')?'btn btn-secondary':'',event:'deny'}));let g=`<div class='jc-tooltip ${d.class}' role='tooltip'>
<div class='jc-arrow'></div>`;return d.question&&0<d.question.length&&(g+='<div class=\'jc-question\'>'+d.question+'</div>'),g+='<div class=\'jc-buttons-wrap\'>',a.each(d.btns,function(h,i){g+=`<div class='jc-button-wrap'>
<a href='#' data-event='${i.event}' class='jc-button ${i.class}'>${i.text}</a>
</div>`}),g+='</div></div>',g},createBackdropHTML:function(){return!!d.backdrop&&`<div class='jc-backdrop jc-${d.backdrop}-backdrop'></div>`},destroy:function(){const g=d.dom_wrapped.data(d.dataAttr);'undefined'!=typeof g&&null!==g&&(g.dom_wrapped.off('touchstart mousedown',g.toggleTooltipHandler),g.dom_wrapped.off('click',g.preventDefaultHandler),a(window).off('resize',g.onResize),g.isVisible()&&g.hide(),g.dom_wrapped.data(g.dataAttr,null))},initialize:function(){return d.dom_wrapped.on('touchstart mousedown',d.toggleTooltipHandler),d.dom_wrapped.on('click',d.preventDefaultHandler),d.dom_wrapped.data(d.dataAttr,d),d.dom},preventDefaultHandler:function(g){return g.preventDefault(),!1},toggleTooltipHandler:function(g){return g.preventDefault(),d.isVisible()?d.hide():d.show(),!1},show:function(g){if(d.isVisible())return!1;null!==a.jConfirm.current&&a.jConfirm.current.hide();const h=a('body');'blurred'===d.backdrop?h.addClass('jc-blurred-body'):d.backdrop&&h.append(d.createBackdropHTML()),h.append(d.createTooltipHTML()),d.tooltip=a('.jc-tooltip'),d.attachTooltipHandlers(),d.positionTooltip(),a(window).on('resize',d.onResize),d.hide_on_click&&a(document).on('touchstart mousedown',d.onClickOutside);const i='jconfirm'+Date.now();d.tooltip.attr('id',i),d.dom.attr('aria-describedby',i),a.jConfirm.current={dom:d.dom,hide:d.hide},('undefined'==typeof g||g)&&d.dom.trigger('jc-show',{tooltip:d.tooltip})},isVisible:function(){return null!==a.jConfirm.current&&d.dom===a.jConfirm.current.dom},hide:function(g){return a(window).off('resize',d.onResize),d.hide_on_click&&a(document).off('touchstart mousedown',d.onClickOutside),d.dom.attr('aria-describedby',null),d.tooltip.remove(),'blurred'===d.backdrop?a('body').removeClass('jc-blurred-body'):d.backdrop&&a('.jc-backdrop').remove(),a.jConfirm.current=null,('undefined'==typeof g||g)&&d.dom.trigger('jc-hide'),d.dom},onResize:function(){d.hide(!1),d.show(!1)},onClickOutside:function(g){const h=a(g.target);h.hasClass('jc-tooltip')||h.parents('.jc-tooltip:first').length||d.hide()},attachTooltipHandlers:function(){d.tooltip.find('.jc-button').on('click',function(g){g.preventDefault();const h=a(this);return d.dom_wrapped.trigger(h.data('event')),d.hide(),'confirm'===h.data('event')&&d.follow_href&&(d.open_new_tab?window.open(d.dom_wrapped.prop('href'),'_blank'):window.location.href=d.dom_wrapped.prop('href')),!1})},positionTooltip:function(){d.positionDebug('-- Start positioning --');let g=d.tooltip.find('.jc-arrow'),[h,i,j,k,l,m]=d.calculateSafePosition(d.position);return('undefined'==typeof l&&(d.positionDebug('Couldn\'t fit preferred position, downsizing and trying again'),d.tooltip.addClass('jc-tight-fit'),[h,m,l,m,l,m]=d.calculateSafePosition(d.position)),'undefined'==typeof l&&'auto'!==d.position&&(d.positionDebug('Couldn\'t fit preferred position'),[h,m,l,m,l,m]=d.calculateSafePosition('auto')),'undefined'==typeof l)?(d.positionDebug('Doesn\'t appear to fit. Displaying centered'),d.tooltip.addClass('jc-centered').css({top:'50%',left:'50%','margin-left':-(j/2),'margin-top':-(k/2)}),g.remove(),void d.positionDebug('-- Done positioning --')):(d.positionDebug({'Setting Position':{Left:l,Top:m}}),d.tooltip.css('left',l),d.tooltip.css('top',m),60>i&&(d.positionDebug('Element is less than '+i+'px. Setting arrow to hug the side tighter'),h+=' jc-arrow-super-hug'),g.addClass('jc-arrow-'+h),d.positionDebug('-- Done positioning --'),d)},calculateSafePosition:function(g){let h=d.tooltip.find('.jc-arrow'),i=d.dom_wrapped.offset(),j=d.dom_wrapped.outerHeight(),k=d.dom_wrapped.outerWidth(),l=parseInt(d.dom_wrapped.css('marginLeft').replace('px','')),m=parseInt(d.dom_wrapped.css('marginTop').replace('px',''));i.left+=l,i.top+=m;let n=d.tooltip.outerWidth(),o=d.tooltip.outerHeight(),p=document.querySelector('body').offsetWidth,q=document.querySelector('body').offsetHeight,r=h.is(':visible')?h.outerHeight():0,s=h.is(':visible')?h.outerWidth():0,t={};t.below=5<q-(o+j+i.top),t.above=5<i.top-o,t.vertical_half=5<i.top+k/2-o/2,t.right=5<p-(n+k+i.left),t.right_half=5<p-i.left-k/2-n/2,t.right_full=5<p-i.left-n,t.left=5<i.left-n,t.left_half=5<i.left+k/2-n/2,t.left_full=5<i.left-n,d.positionDebug({'Clicked Element':{Left:i.left,Top:i.top}}),d.positionDebug({'Element Dimensions':{Height:j,Width:k},'Tooltip Dimensions':{Height:o,Width:n},'Window Dimensions':{Height:q,Width:p},'Arrow Dimensions':{Height:r,Width:s}}),d.positionDebug(t);let u,v,w;return('auto'===g||'bottom'===g)&&t.below&&t.left_half&&t.right_half?(d.positionDebug('Displaying below, centered'),u='top',v=i.left-n/2+k/2,w=i.top+j+r/2):('auto'===g||'top'===g)&&t.above&&t.left_half&&t.right_half?(d.positionDebug('Displaying above, centered'),u='bottom',v=i.left-n/2+k/2,w=i.top-o-r/2):('auto'===g||'left'===g)&&t.left&&t.vertical_half?(d.positionDebug('Displaying left, centered'),u='right',v=i.left-n-s/2,w=i.top+j/2-o/2):('auto'===g||'right'===g)&&t.right&&t.vertical_half?(d.positionDebug('Displaying right, centered'),u='left',v=i.left+k+s/2,w=i.top+j/2-o/2):('auto'===g||'bottom'===g)&&t.below&&t.right_full?(d.positionDebug('Displaying below, to the right'),u='top jt-arrow-hug-left',v=i.left,w=i.top+j+r/2):('auto'===g||'bottom'===g)&&t.below&&t.left_full?(d.positionDebug('Displaying below, to the left'),u='top jt-arrow-hug-right',v=i.left+k-n,w=i.top+j+r/2):('auto'===g||'top'===g)&&t.above&&t.right_full?(d.positionDebug('Displaying above, to the right'),u='bottom jt-arrow-hug-left',v=i.left,w=i.top-o-r/2):('auto'==g||'top'==g)&&t.above&&t.left_full&&(d.positionDebug('Displaying above, to the left'),u='bottom jt-arrow-hug-right',v=i.left+k-n,w=i.top-o-r/2),[u,k,n,o,v,w]},positionDebug:function(g){return!!d.position_debug&&('object'==typeof g?console.table(g):console.log(`Position: ${g}`))}};d.destroy();var f=d.initialize();return d.show_now&&d.show(),f},a.jConfirm={},a.jConfirm.current=null,a.jConfirm.defaults={btns:!1,position_debug:!1,question:'Are you sure?',confirm_text:'Yes',deny_text:'No',follow_href:!1,open_new_tab:!1,hide_on_click:!0,position:'auto',class:'',show_deny_btn:!0,theme:'black',size:'small',backdrop:!1,show_now:!1}})(jQuery);
(function(a){a.fn.jConfirm=function(b){var c=a(this);if(1<this.length)return this.each(function(){a(this).jConfirm(b)}),this;if("undefined"==typeof this||1!==this.length)return this;b=a.extend({},a.jConfirm.defaults,b,c.data()),b.class+=" jc-"+b.theme+"-theme",b.class+=" jc-"+b.size;let d={dom:this,dom_wrapped:c,position_debug:b.position_debug,follow_href:b.follow_href,open_new_tab:b.open_new_tab,hide_on_click:b.hide_on_click,question:b.question,theme:b.theme,class:b.class,backdrop:b.backdrop,btns:b.btns,confirm_text:b.confirm_text,deny_text:b.deny_text,show_deny_btn:b.show_deny_btn,position:b.position,show_now:b.show_now,dataAttr:"jConfirm",createTooltipHTML:function(){d.btns||(d.btns=[{text:d.confirm_text,class:-1<d.theme.indexOf("bootstrap")?"btn btn-success":"jc-button-highlight",event:"confirm"}],d.show_deny_btn&&d.btns.push({text:d.deny_text,class:-1<d.theme.indexOf("bootstrap")?"btn btn-secondary":"",event:"deny"}));let b=`<div class='jc-tooltip ${d.class}' role='tooltip'>
<div class='jc-arrow'></div>`;return d.question&&0<d.question.length&&(b+="<div class='jc-question'>"+d.question+"</div>"),b+="<div class='jc-buttons-wrap'>",a.each(d.btns,function(a,c){b+=`<div class='jc-button-wrap'>
<a href='#' data-event='${c.event}' class='jc-button ${c.class}'>${c.text}</a>
</div>`}),b+="</div></div>",b},createBackdropHTML:function(){return!!d.backdrop&&`<div class='jc-backdrop jc-${d.backdrop}-backdrop'></div>`},destroy:function(){const b=d.dom_wrapped.data(d.dataAttr);"undefined"!=typeof b&&null!==b&&(b.dom_wrapped.off("touchstart mousedown",b.toggleTooltipHandler),b.dom_wrapped.off("click",b.preventDefaultHandler),a(window).off("resize",b.onResize),b.isVisible()&&b.hide(),b.dom_wrapped.data(b.dataAttr,null))},initialize:function(){return d.dom_wrapped.on("touchstart mousedown",d.toggleTooltipHandler),d.dom_wrapped.on("click",d.preventDefaultHandler),d.dom_wrapped.data(d.dataAttr,d),d.dom},preventDefaultHandler:function(a){return a.preventDefault(),!1},toggleTooltipHandler:function(a){return a.preventDefault(),d.isVisible()?d.hide():d.show(),!1},show:function(b){if(d.isVisible())return!1;null!==a.jConfirm.current&&a.jConfirm.current.hide();const c=a("body");"blurred"===d.backdrop?c.addClass("jc-blurred-body"):d.backdrop&&c.append(d.createBackdropHTML()),c.append(d.createTooltipHTML()),d.tooltip=a(".jc-tooltip"),d.attachTooltipHandlers(),d.positionTooltip(),a(window).on("resize",d.onResize),d.hide_on_click&&a(document).on("touchstart mousedown",d.onClickOutside);const e="jconfirm"+Date.now();d.tooltip.attr("id",e),d.dom.attr("aria-describedby",e),a.jConfirm.current={dom:d.dom,hide:d.hide},("undefined"==typeof b||b)&&d.dom.trigger("jc-show",{tooltip:d.tooltip})},isVisible:function(){return null!==a.jConfirm.current&&d.dom===a.jConfirm.current.dom},hide:function(b){return a(window).off("resize",d.onResize),d.hide_on_click&&a(document).off("touchstart mousedown",d.onClickOutside),d.dom.attr("aria-describedby",null),d.tooltip.remove(),"blurred"===d.backdrop?a("body").removeClass("jc-blurred-body"):d.backdrop&&a(".jc-backdrop").remove(),a.jConfirm.current=null,("undefined"==typeof b||b)&&d.dom.trigger("jc-hide"),d.dom},onResize:function(){d.hide(!1),d.show(!1)},onClickOutside:function(b){const c=a(b.target);c.hasClass("jc-tooltip")||c.parents(".jc-tooltip:first").length||d.hide()},attachTooltipHandlers:function(){d.tooltip.find(".jc-button").on("click",function(b){b.preventDefault();const c=a(this);return d.dom_wrapped.trigger(c.data("event")),d.hide(),"confirm"===c.data("event")&&d.follow_href&&(d.open_new_tab?window.open(d.dom_wrapped.prop("href"),"_blank"):window.location.href=d.dom_wrapped.prop("href")),!1})},positionTooltip:function(){d.positionDebug("-- Start positioning --");let a=d.tooltip.find(".jc-arrow"),[b,c,e,f,g,h]=d.calculateSafePosition(d.position);return("undefined"==typeof g&&(d.positionDebug("Couldn't fit preferred position, downsizing and trying again"),d.tooltip.addClass("jc-tight-fit"),[b,c,e,f,g,h]=d.calculateSafePosition(d.position)),"undefined"==typeof g&&"auto"!==d.position&&(d.positionDebug("Couldn't fit preferred position"),[b,c,e,f,g,h]=d.calculateSafePosition("auto")),"undefined"==typeof g)?(d.positionDebug("Doesn't appear to fit. Displaying centered"),d.tooltip.addClass("jc-centered").css({top:"50%",left:"50%","margin-left":-(e/2),"margin-top":-(f/2)}),a.remove(),void d.positionDebug("-- Done positioning --")):(d.positionDebug({"Setting Position":{Left:g,Top:h}}),d.tooltip.css("left",g),d.tooltip.css("top",h),60>c&&(d.positionDebug("Element is less than "+c+"px. Setting arrow to hug the side tighter"),b+=" jc-arrow-super-hug"),a.addClass("jc-arrow-"+b),d.positionDebug("-- Done positioning --"),d)},calculateSafePosition:function(a){let b=d.tooltip.find(".jc-arrow"),c=d.tooltip.outerWidth(),e=d.tooltip.outerHeight();if(0===d.dom_wrapped.length)return d.position="auto",["none",0,c,e,"undefined"];let f=d.dom_wrapped.offset(),g=d.dom_wrapped.outerHeight(),h=d.dom_wrapped.outerWidth(),i=parseInt(d.dom_wrapped.css("marginLeft").replace("px","")),j=parseInt(d.dom_wrapped.css("marginTop").replace("px",""));f.left+=i,f.top+=j;let k=document.querySelector("body").offsetWidth,l=document.querySelector("body").offsetHeight,m=b.is(":visible")?b.outerHeight():0,n=b.is(":visible")?b.outerWidth():0,o={};o.below=5<l-(e+g+f.top),o.above=5<f.top-e,o.vertical_half=5<f.top+h/2-e/2,o.right=5<k-(c+h+f.left),o.right_half=5<k-f.left-h/2-c/2,o.right_full=5<k-f.left-c,o.left=5<f.left-c,o.left_half=5<f.left+h/2-c/2,o.left_full=5<f.left-c,d.positionDebug({"Clicked Element":{Left:f.left,Top:f.top}}),d.positionDebug({"Element Dimensions":{Height:g,Width:h},"Tooltip Dimensions":{Height:e,Width:c},"Window Dimensions":{Height:l,Width:k},"Arrow Dimensions":{Height:m,Width:n}}),d.positionDebug(o);let p,q,r;return("auto"===a||"bottom"===a)&&o.below&&o.left_half&&o.right_half?(d.positionDebug("Displaying below, centered"),p="top",q=f.left-c/2+h/2,r=f.top+g+m/2):("auto"===a||"top"===a)&&o.above&&o.left_half&&o.right_half?(d.positionDebug("Displaying above, centered"),p="bottom",q=f.left-c/2+h/2,r=f.top-e-m/2):("auto"===a||"left"===a)&&o.left&&o.vertical_half?(d.positionDebug("Displaying left, centered"),p="right",q=f.left-c-n/2,r=f.top+g/2-e/2):("auto"===a||"right"===a)&&o.right&&o.vertical_half?(d.positionDebug("Displaying right, centered"),p="left",q=f.left+h+n/2,r=f.top+g/2-e/2):("auto"===a||"bottom"===a)&&o.below&&o.right_full?(d.positionDebug("Displaying below, to the right"),p="top jt-arrow-hug-left",q=f.left,r=f.top+g+m/2):("auto"===a||"bottom"===a)&&o.below&&o.left_full?(d.positionDebug("Displaying below, to the left"),p="top jt-arrow-hug-right",q=f.left+h-c,r=f.top+g+m/2):("auto"===a||"top"===a)&&o.above&&o.right_full?(d.positionDebug("Displaying above, to the right"),p="bottom jt-arrow-hug-left",q=f.left,r=f.top-e-m/2):("auto"===a||"top"===a)&&o.above&&o.left_full&&(d.positionDebug("Displaying above, to the left"),p="bottom jt-arrow-hug-right",q=f.left+h-c,r=f.top-e-m/2),[p,h,c,e,q,r]},positionDebug:function(a){return!!d.position_debug&&("object"==typeof a?console.table(a):console.log(`Position: ${a}`))}};d.destroy();var e=d.initialize();return d.show_now&&d.show(),e},a.jConfirm={},a.jConfirm.current=null,a.jConfirm.defaults={btns:!1,position_debug:!1,question:"Are you sure?",confirm_text:"Yes",deny_text:"No",follow_href:!1,open_new_tab:!1,hide_on_click:!0,position:"auto",class:"",show_deny_btn:!0,theme:"black",size:"small",backdrop:!1,show_now:!1}})(jQuery);
{
"name": "jconfirm",
"version": "4.4.1",
"version": "4.4.2",
"description": "jQuery confirmation tooltip plugin",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc