Skip to content

Commit

Permalink
ignore_global_close method
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Reitman committed Jun 12, 2015
1 parent 0d1186b commit 8bade10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions docs/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

$('#no-global-co').clickover({ global_close: false });

$('#ignore-global-co').clickover({ global_close: false });

$('#shown-co').clickover({
onShown: function () { alert("Hello from clickover"); }
});
Expand Down Expand Up @@ -205,6 +207,20 @@ <h3>Changing defaults</h3>
</pre>
</p>

<h3>Disable global_close temporarily</h3>
<p> Sometimes you want the global_close option, but when some modal is
shown overtop your popover you want to make sure that the popover
stays open until the modal goes away.
</p>
<pre>
$(your_element).data().clickover.ignore_global_close(true)
</pre>
when you are done, re-enable global close:
<pre>
$(your_element).data().clickover.ignore_global_close(false)
</pre>
</p>

<h3>Markup</h3>
<p>Just like Tooltip and Popover, Clickover is opt in data-api.</p>
<pre>$('[rel="clickover"]').clickover()</pre>
Expand Down
7 changes: 6 additions & 1 deletion js/bootstrapx-clickover.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@

constructor: Clickover

, ignore_global_close: function( ignore ) {
this.attr.ignore_global_close = ignore;
}

, cinit: function( type, element, options ) {
this.attr = {};

// choose random attrs instead of timestamp ones
this.attr.me = ((Math.random() * 10) + "").replace(/\D/g, '');
this.attr.click_event_ns = "click." + this.attr.me + " touchstart." + this.attr.me;
this.attr.ignore_global_close = false;

if (!options) options = {};

Expand Down Expand Up @@ -73,7 +78,7 @@
// close on global request, exclude clicks inside clickover
this.options.global_close &&
$('body').on( this.attr.click_event_ns, function(e) {
if ( !that.tip().has(e.target).length ) { that.clickery(); }
if ( !that.attr.ignore_global_close && !that.tip().has(e.target).length ) { that.clickery(); }
});

this.options.esc_close && $(document).bind('keyup.clickery', function(e) {
Expand Down

0 comments on commit 8bade10

Please sign in to comment.