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.2.1 to 4.2.2

108

jConfirm.js

@@ -53,9 +53,2 @@ /*

createTooltipHTML: function(){
let html = '';
html += "<div class='jc-tooltip "+helper.class+"' role='tooltip'>";
html += "<div class='jc-arrow'></div>";
if( helper.question && helper.question.length > 0 ) {
html += "<div class='jc-question'>"+helper.question+"</div>";
}
html += "<div class='jc-buttons-wrap'>";

@@ -68,3 +61,3 @@ //if no buttons were provided (default), set confirm and deny

text: helper.confirm_text,
class: helper.theme.indexOf('bootstrap') > -1 ? 'btn btn-success jc-confirm' : 'jc-confirm jc-button-highlight',
class: helper.theme.indexOf('bootstrap') > -1 ? 'btn btn-success' : 'jc-button-highlight',
event: 'confirm'

@@ -78,3 +71,3 @@ }

text: helper.deny_text,
class: helper.theme.indexOf('bootstrap') > -1 ? 'btn btn-secondary jc-deny' : 'jc-deny',
class: helper.theme.indexOf('bootstrap') > -1 ? 'btn btn-secondary' : '',
event: 'deny'

@@ -85,13 +78,20 @@ });

let html = `<div class='jc-tooltip ${helper.class}' role='tooltip'>
<div class='jc-arrow'></div>`;
if( helper.question && helper.question.length > 0 ) {
html += "<div class='jc-question'>"+helper.question+"</div>";
}
html += "<div class='jc-buttons-wrap'>";
//loop through buttons and add to html
$.each(helper.btns, function(key,btn){
html += "<div class='jc-button-wrap'>";
html += "<a href='#' data-event='"+btn.event+"' class='jc-button "+btn.class+"'>"+btn.text+"</a>";
html += "</div>";
html += `<div class='jc-button-wrap'>
<a href='#' data-event='${btn.event}' class='jc-button ${btn.class}'>${btn.text}</a>
</div>`;
});
//end buttons wrap
html += "</div>";
//end tooltip
html += "</div>";
//end buttons wrap and tooltip
html += "</div></div>";
return html;

@@ -101,3 +101,3 @@ },

createBackdropHTML: function(){
return helper.backdrop ? "<div class='jc-backdrop jc-"+helper.backdrop+"-backdrop'></div>" : false;
return helper.backdrop ? `<div class='jc-backdrop jc-${helper.backdrop}-backdrop'></div>` : false;
},

@@ -335,3 +335,3 @@ //disable existing options/handlers

//position the tooltip
helper.positionDebug('Setting position: left:'+left+' top:'+top);
helper.positionDebug({'Setting Position':{'Left':left,'Top':top}});
helper.tooltip.css('left', left);

@@ -385,35 +385,30 @@ helper.tooltip.css('top', top);

//see where it fits in relation to the clicked element
let fits_below = (window_height - (tooltip_height+elem_height+elem_position.top)) > 5;
let fits_below_half = (window_height - (elem_width/2) - elem_position.top - (tooltip_height/2)) > 5;
let fits_above = (elem_position.top - tooltip_height) > 5;
let fits_above_half = (elem_position.top - (elem_width/2) - (tooltip_height/2)) > 5;
let fits_right = (window_width - (tooltip_width+elem_width+elem_position.left)) > 5;
let fits_right_half = (window_width - elem_position.left - (elem_width/2) - (tooltip_width/2)) > 5;
let fits_right_full = (window_width - elem_position.left - tooltip_width) > 5;
let fits_left = (elem_position.left - tooltip_width) > 5;
let fits_left_half = (elem_position.left - (elem_width/2) - (tooltip_width/2)) > 5;
let fits_left_full = (elem_position.left - tooltip_width) > 5;
let fits = {};
fits.below = (window_height - (tooltip_height+elem_height+elem_position.top)) > 5;
fits.below_half = (window_height - (elem_width/2) - elem_position.top - (tooltip_height/2)) > 5;
fits.above = (elem_position.top - tooltip_height) > 5;
fits.above_half = (elem_position.top - (elem_width/2) - (tooltip_height/2)) > 5;
fits.right = (window_width - (tooltip_width+elem_width+elem_position.left)) > 5;
fits.right_half = (window_width - elem_position.left - (elem_width/2) - (tooltip_width/2)) > 5;
fits.right_full = (window_width - elem_position.left - tooltip_width) > 5;
fits.left = (elem_position.left - tooltip_width) > 5;
fits.left_half = (elem_position.left - (elem_width/2) - (tooltip_width/2)) > 5;
fits.left_full = (elem_position.left - tooltip_width) > 5;
//in debug mode, display all details
helper.positionDebug('Clicked element position: left:'+elem_position.left+' top:'+elem_position.top);
helper.positionDebug('Element dimensions: height:'+elem_height+' width:'+elem_width);
helper.positionDebug('Tooltip dimensions: height:'+tooltip_height+' width:'+tooltip_width);
helper.positionDebug('Window dimensions: height:'+window_height+' width:'+window_width);
helper.positionDebug('Arrow dimensions: height:'+arrow_height+' width:'+arrow_width);
helper.positionDebug({
'Clicked Element': {'Left': elem_position.left, 'Top': elem_position.top},
});
helper.positionDebug({
'Element Dimensions':{'Height':elem_height, 'Width':elem_width},
'Tooltip Dimensions':{'Height':tooltip_height, 'Width':tooltip_width},
'Window Dimensions':{'Height':window_height, 'Width':window_width},
'Arrow Dimensions':{'Height':arrow_height, 'Width':arrow_width},
});
helper.positionDebug(fits);
if(fits_below){ helper.positionDebug('Fits below: '+fits_below); }
if(fits_below_half){ helper.positionDebug('Fits below half (for vertical centering): '+fits_below_half); }
if(fits_above){ helper.positionDebug('Fits above: '+fits_above); }
if(fits_above_half){ helper.positionDebug('Fits above half (for vertical centering): '+fits_above_half); }
if(fits_right){ helper.positionDebug('Fits right (to the right of the element):'+fits_right); }
if(fits_right_half){ helper.positionDebug('Fits right half (for horizontal centering): '+fits_right_half); }
if(fits_right_full){ helper.positionDebug('Fits right full (starting where element starts): '+fits_right_full); }
if(fits_left){ helper.positionDebug('Fits left (to the left of the element): '+fits_left); }
if(fits_left_half){ helper.positionDebug('Fits left half (for horizontal centering): '+fits_left_half); }
if(fits_left_full){ helper.positionDebug('Fits left full (starting where element starts): '+fits_left_full); }
//vars we need for positioning
let arrow_dir, left, top;
if( (position === 'auto' || position === 'bottom') && fits_below && fits_left_half && fits_right_half )
if( (position === 'auto' || position === 'bottom') && fits.below && fits.left_half && fits.right_half )
{

@@ -425,3 +420,3 @@ helper.positionDebug('Displaying below, centered');

}
else if( (position === 'auto' || position === 'top') && fits_above && fits_left_half && fits_right_half )
else if( (position === 'auto' || position === 'top') && fits.above && fits.left_half && fits.right_half )
{

@@ -433,3 +428,3 @@ helper.positionDebug('Displaying above, centered');

}
else if( (position === 'auto' || position === 'left') && fits_left && fits_below_half && fits_above_half )
else if( (position === 'auto' || position === 'left') && fits.left && fits.below_half && fits.above_half )
{

@@ -441,3 +436,3 @@ helper.positionDebug('Displaying left, centered');

}
else if( (position === 'auto' || position === 'right') && fits_right && fits_below_half && fits_above_half )
else if( (position === 'auto' || position === 'right') && fits.right && fits.below_half && fits.above_half )
{

@@ -449,3 +444,3 @@ helper.positionDebug('Displaying right, centered');

}
else if( (position === 'auto' || position === 'bottom') && fits_below && fits_right_full )
else if( (position === 'auto' || position === 'bottom') && fits.below && fits.right_full )
{

@@ -457,3 +452,3 @@ helper.positionDebug('Displaying below, to the right');

}
else if( (position === 'auto' || position === 'bottom') && fits_below && fits_left_full )
else if( (position === 'auto' || position === 'bottom') && fits.below && fits.left_full )
{

@@ -465,3 +460,3 @@ helper.positionDebug('Displaying below, to the left');

}
else if( (position === 'auto' || position === 'top') && fits_above && fits_right_full )
else if( (position === 'auto' || position === 'top') && fits.above && fits.right_full )
{

@@ -473,3 +468,3 @@ helper.positionDebug('Displaying above, to the right');

}
else if( (position === 'auto' || position === 'top') && fits_above && fits_left_full )
else if( (position === 'auto' || position === 'top') && fits.above && fits.left_full )
{

@@ -486,6 +481,7 @@ helper.positionDebug('Displaying above, to the left');

positionDebug: function(msg){
if( helper.position_debug )
{
console.log('Position: '+msg);
if( !helper.position_debug ) {
return false;
}
return typeof msg === 'object' ? console.table(msg) : console.log(`Position: ${msg}`);
}

@@ -505,3 +501,3 @@ };

btns: false,
position_debug: true,
position_debug: false,
question: 'Are you sure?',

@@ -508,0 +504,0 @@ confirm_text: 'Yes',

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

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

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

@@ -16,2 +16,12 @@ jConfirm

Features
=======
* Backdrops (black, white, blurred)
* Themes (black, white, bootstrap 4, bootstrap 4 white)
* Sizes (tiny, small, medium, large)
* Responsive (prefers the supplied position, if it doesn't fit, it attempts to make it smaller by stacking the question and buttons, if it doesn't fit, it tries the "auto" setting, if it still doesn't fit, it shows as a modal in the middle of the screen)
* Customizable buttons and events
* No-conflict CSS
* Additional events like tooltip hide/show for extra control
Getting the files

@@ -18,0 +28,0 @@ =======

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