Skip to content

Commit

Permalink
had to remove target option because it's too error prone
Browse files Browse the repository at this point in the history
  • Loading branch information
HTMLGuyLLC committed Oct 25, 2018
1 parent 7762861 commit 0228e16
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ $(function(){
size: 'small',
//boolean: show the tooltip immediately on instantiation
show_now: false,
//string|null: tie the handler to a child of the supplier dom element (good for dynamically added elements)
//for example: $('body').jConfirm({'target':'a.confirm'}).on('confirm', function(){ });
target: null,
//string|false ('black', 'white', 'blurred')
backdrop: false
}).on('confirm', function(e){
Expand Down
5 changes: 1 addition & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ <h4>All options and events with defaults:</h4>
size: 'small',
//boolean: show the tooltip immediately on instantiation
show_now: false,
//string|null: tie the handler to a child of the supplier dom element (good for dynamically added elements)
//for example: $('body').jConfirm({'target':'a.confirm'}).on('confirm', function(){ });
target: null,
//string: class(es) to add to the tooltip
'class': ''
}).on('confirm', function(e){
Expand Down Expand Up @@ -474,7 +471,7 @@ <h4>Social Media Sharing:</h4>
}).on('jc-hide', function(e){
console.log('js-hide');
});
})
});
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
Expand Down
15 changes: 7 additions & 8 deletions jConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
;(function($) {

$.fn.jConfirm = function(options) {
var this_wrapped = $(this);

//Instantiate jConfirm once per dom element
if (this.length > 1){
Expand All @@ -24,7 +25,7 @@
}

//get list of options
options = $.extend({}, $.jConfirm.defaults, options, $(this).data());
options = $.extend({}, $.jConfirm.defaults, options, this_wrapped.data());

//add theme class
options.class += ' jc-'+options.theme+'-theme';
Expand All @@ -33,7 +34,7 @@

let helper = {
dom: this,
dom_wrapped: $(this),
dom_wrapped: this_wrapped,
position_debug: options.position_debug,
follow_href: options.follow_href,
open_new_tab: options.open_new_tab,
Expand All @@ -48,7 +49,6 @@
show_deny_btn: options.show_deny_btn,
position: options.position,
show_now: options.show_now,
target: options.target,
dataAttr: 'jConfirm',
//create tooltip html
createTooltipHTML: function(){
Expand Down Expand Up @@ -105,8 +105,8 @@
if( typeof existing !== 'undefined' && existing !== null ) {

//disable handler
existing.dom_wrapped.off('touchstart mousedown', helper.target, existing.toggleTooltipHandler);
existing.dom_wrapped.off('click', helper.target, existing.preventDefaultHandler);
existing.dom_wrapped.off('touchstart mousedown', existing.toggleTooltipHandler);
existing.dom_wrapped.off('click', existing.preventDefaultHandler);

//attach resize handler to reposition tooltip
$(window).off('resize', existing.onResize);
Expand All @@ -123,8 +123,8 @@
//attach on handler to show tooltip
//use touchstart and mousedown just like if you click outside the tooltip to close it
//this way it blocks the hide if you click the button a second time to close the tooltip
helper.dom_wrapped.on('touchstart mousedown', helper.target, helper.toggleTooltipHandler);
helper.dom_wrapped.on('click', helper.target, helper.preventDefaultHandler);
helper.dom_wrapped.on('touchstart mousedown', helper.toggleTooltipHandler);
helper.dom_wrapped.on('click', helper.preventDefaultHandler);

//attach to dom for easy access later
helper.dom_wrapped.data(helper.dataAttr, helper);
Expand Down Expand Up @@ -507,7 +507,6 @@
size: 'small',
backdrop: false,
show_now: false,
target: null,
}

})(jQuery);
8 changes: 4 additions & 4 deletions jConfirm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jconfirm",
"version": "4.3.0",
"version": "4.4.0",
"description": "jQuery confirmation tooltip plugin",
"repository": {
"type": "git",
Expand Down

0 comments on commit 0228e16

Please sign in to comment.