Skip to content

Commit

Permalink
Merge pull request #31 from christiannaths/master
Browse files Browse the repository at this point in the history
New Option: add additional css class(es) to close link
  • Loading branch information
kylefox committed Dec 22, 2013
2 parents c0de654 + 33c0c20 commit ac052dd
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ These are the supported options and their default values:
escapeClose: true, // Allows the user to close the modal by pressing `ESC`
clickClose: true, // Allows the user to close the modal by clicking the overlay
closeText: 'Close', // Text content for the close <a> tag.
closeClass: '', // Add additional class(es) to the close <a> tag.
showClose: true, // Shows a (X) icon/link in the top-right corner
modalClass: "modal", // CSS class added to the element being displayed in the modal.
spinnerHtml: null, // HTML appended to the default spinner during AJAX requests.
Expand Down
68 changes: 68 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,66 @@ <h2>Example 7: Fade Transitions</h2>
<p>This modal starts fading in well after the overlay has finished transitioning.</p>
</div>

<hr/>

<h2>Example 10: Custom Class for Close Button</h2>
<p>
This <a href="#ex10">example</a> demonstrates how to add extra classes to the close button (for custom styles for the close button):
</p>

<pre><code> $("#custom-close").modal({
closeClass: 'icon-remove',
closeText: '!'
});</code></pre>
<p>And then of course your custom CSS</p>
<pre><code>.modal a.close-modal[class*="icon-"] {
top: -10px;
right: -10px;
width: 20px;
height: 20px;
color: #fff;
line-height: 1.25;
text-align: center;
text-decoration: none;
text-indent: 0;
background: #900;
border: 2px solid #fff;
-webkit-border-radius: 26px;
-moz-border-radius: 26px;
-o-border-radius: 26px;
-ms-border-radius: 26px;
-moz-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
-webkit-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
}</code></pre>

<div id="ex10" class="modal">
<p>This modal has a fancy-shmancy close button.</p>
</div>

<style type="text/css">
.modal a.close-modal[class*="icon-"] {
top: -10px;
right: -10px;
width: 20px;
height: 20px;
color: #fff;
line-height: 1.25;
text-align: center;
text-decoration: none;
text-indent: 0;
background: #900;
border: 2px solid #fff;
-webkit-border-radius: 26px;
-moz-border-radius: 26px;
-o-border-radius: 26px;
-ms-border-radius: 26px;
-moz-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
-webkit-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
}
</style>

<script type="text/javascript" charset="utf-8">
$(function() {

Expand Down Expand Up @@ -308,6 +368,14 @@ <h2>Example 7: Fade Transitions</h2>
});
});

$('a[href="#ex10"]').click(function(event){
event.preventDefault();
$(this).modal({
closeClass: 'icon-remove',
closeText: '!'
});
});

});
</script>
</body>
Expand Down
7 changes: 4 additions & 3 deletions jquery.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
show: function() {
this.$elm.trigger($.modal.BEFORE_OPEN, [this._ctx()]);
if (this.options.showClose) {
this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal">' + this.options.closeText + '</a>');
this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>');
this.$elm.append(this.closeButton);
}
this.$elm.addClass(this.options.modalClass + ' current');
Expand Down Expand Up @@ -175,11 +175,11 @@
if (!current) return;
current.resize();
};

// Returns if there currently is an active modal
$.modal.isActive = function () {
return current ? true : false;
}
}

$.modal.defaults = {
overlay: "#000",
Expand All @@ -188,6 +188,7 @@
escapeClose: true,
clickClose: true,
closeText: 'Close',
closeClass: '',
modalClass: "modal",
spinnerHtml: null,
showSpinner: true,
Expand Down
9 changes: 1 addition & 8 deletions jquery.modal.min.js

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

0 comments on commit ac052dd

Please sign in to comment.