Skip to content

Commit

Permalink
Added an image ... *sigh*. Bumped version to 0.2.1 (will start doing …
Browse files Browse the repository at this point in the history
…patch version increments for minor fixes).
  • Loading branch information
kylefox committed Nov 19, 2010
1 parent 38d3e66 commit 3da2f27
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 10 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ By contrast, this plugin handles the two most common scenarios I run into
* displaying an existing DOM element
* loading a page with AJAX

and does so with as little HTML & CSS as possible -- and **no images.**

This comment has been minimized.

Copy link
@darkhelmet

darkhelmet Mar 28, 2011

I can't tell if you actually deleted this or if the single tear you shed while adding the image dripped, causing this to go away.

This comment has been minimized.

Copy link
@kylefox

kylefox Mar 28, 2011

Author Owner

Hah. I shamefully had to remove it.

This comment has been minimized.

Copy link
@jpwesterhof

jpwesterhof Feb 7, 2014

I know your pain. However, this can be solved bij changing 'url([url_to_image])' to 'url(data:image/[mime_type];base64,[base64_representation_of_the_image])'. I think you can figure it out yourself but if you need help please contact me. I changed this in my implementation of your modal. Thanks anyway!

This comment has been minimized.

Copy link
@kylefox

kylefox Feb 7, 2014

Author Owner

Base64 isn't a bad idea for this scenario! If you submit a pull request with that change I'd merge it :)

and does so with as little HTML & CSS as possible.

# Installation

Expand Down Expand Up @@ -78,6 +78,20 @@ However, when this occurs, you will probably want to at least re-center the moda

$.fn.modal.resize()

# Options

These are the supported options and their default values:

$.fn.modal.defaults = {
overlay: "#000", // Overlay color
opacity: 0.75, // Overlay opacity
zIndex: 1, // Overlay z-index.
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
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.
};

# Events

The following events are triggered on the modal element at various points in the open/close cycle. Hopefully the names are self-explanatory.
Expand Down
Binary file added close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 29 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<script type="text/javascript" charset="utf-8"> hljs.initHighlightingOnLoad(); </script>
<link rel="stylesheet" href="highlight/github.css" type="text/css" media="screen" />
<style type="text/css" media="screen">
body { font: normal 14px/21px "Helvetica Neue", Arial, sans-serif; color: #777; padding: 30px 60px; }
html { background: #ddd; }
body { font: normal 14px/21px "Helvetica Neue", Arial, sans-serif; color: #777; padding: 30px 60px; width: 740px; margin: 0 auto; background: #fff; }
small { color: #aaa; }
h1,h2,h3,h4 { color: #444; }
a { color: #0086B3; font-weight: bold; }
Expand Down Expand Up @@ -78,7 +79,7 @@ <h1>jQuery Modal</h1>

<hr />

<h3>Example 1 (simplest): Open &amp; Close with links</h3>
<h2>Example 1 (simplest): Open &amp; Close with links</h2>
<ol>
<li>Embed modal HTML in document <small>(and hide it)</small></li>
<li>Create a link with <code>rel="modal:open"</code> and set the <code>href</code> attribute to the modal's DOM id.</li>
Expand Down Expand Up @@ -142,6 +143,23 @@ <h2>Example 3: resizing</h2>
<h2>Example 4: AJAX</h2>
<p>This <a href="ajax.html" rel="modal:open">example</a> loads HTML with AJAX.</p>

<hr />

<h2>Example 5: the un-closable window</h2>
<p>
This <a href="#ex5">example</a> demonstrates how to disable the default methods of closing the modal:

<pre><code> $("#sticky").modal({
escapeClose: false,
clickClose: false,
showClose: false
});</code></pre>


</p>
<div id="ex5" class="modal">
<p>If you do this, be sure to provide the user with an alternate method of <a href="#" rel="modal:close">closing the window.</a></p>
</div>

<script type="text/javascript" charset="utf-8">
$(function() {
Expand All @@ -163,6 +181,15 @@ <h2>Example 4: AJAX</h2>
return false;
});

$('a[href="#ex5"]').click(function() {
$($(this).attr('href')).modal({
escapeClose: false,
clickClose: false,
showClose: false
});
return false;
});

});
</script>
</body>
Expand Down
11 changes: 11 additions & 0 deletions jquery.modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@
-webkit-box-shadow: 0 0 10px #000;
-moz-box-shadow: 0 0 10px #000;
box-shadow: 0 0 10px #000;
}

.modal a.close-modal {
position: absolute;
top: -12.5px;
right: -12.5px;
display: block;
width: 30px;
height: 30px;
text-indent: -9999px;
background: url(close.png) no-repeat 0 0;
}
8 changes: 6 additions & 2 deletions jquery.modal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
A simple jQuery modal (https://github.com/kylefox/jquery-modal)
Version 0.2
Version 0.2.1
*/
(function() {

Expand Down Expand Up @@ -41,6 +41,9 @@

function show() {
center_modal(current_modal);
if(options.showClose) {
current_modal.elm.append('<a href="#close-modal" rel="modal:close" class="close-modal">Close</a>');
}
$elm.addClass(options.modalClass).addClass('current').show();
$elm.trigger($.fn.modal.OPEN, [current_modal]);
}
Expand All @@ -58,7 +61,8 @@
zIndex: 1,
escapeClose: true,
clickClose: true,
modalClass: "modal"
modalClass: "modal",
showClose: true
};

// Event constants:
Expand Down
7 changes: 4 additions & 3 deletions jquery.modal.min.js

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

4 changes: 2 additions & 2 deletions jquery.modal.pack.js

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

0 comments on commit 3da2f27

Please sign in to comment.