Skip to content

Commit

Permalink
bind events by data-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Poluektov Dmitriy authored and vodkabears committed Apr 19, 2015
1 parent b3a2f4a commit de6ffe6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
2 changes: 0 additions & 2 deletions dist/jquery.remodal.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Made by Ilya Makarov
* Under MIT License
*/
@import url(//fonts.googleapis.com/css?family=Exo+2:700,400&subset=latin,cyrillic);

/* ==========================================================================
Remodal necessary styles
========================================================================== */
Expand Down
8 changes: 5 additions & 3 deletions dist/jquery.remodal.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
}

remodal.$bg = $('.' + namespace + '-bg');
remodal.$closeButton = $('<a href="#"></a>').addClass(namespace + '-close');

remodal.$wrapper = $('<div>').addClass(namespace + '-wrapper');
remodal.$modal = $modal;
remodal.$modal.addClass(namespace);
Expand All @@ -251,8 +251,10 @@
remodal.$modal.append(remodal.$closeButton);
remodal.$wrapper.append(remodal.$modal);
remodal.$body.append(remodal.$wrapper);
remodal.$confirmButton = remodal.$modal.find('.' + namespace + '-confirm');
remodal.$cancelButton = remodal.$modal.find('.' + namespace + '-cancel');

remodal.$closeButton = remodal.$modal.find('[data-' + namespace + '-action="close"]');
remodal.$confirmButton = remodal.$modal.find('[data-' + namespace + '-action="confirm"]');
remodal.$cancelButton = remodal.$modal.find('[data-' + namespace + '-action="cancel"]');

// Calculate timeouts
tdOverlay = getTransitionDuration(remodal.$overlay);
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.remodal.min.js

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

7 changes: 4 additions & 3 deletions examples/index-zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h1>Remodal</h1>
</div>

<div class="remodal" data-remodal-id="modal">
<span data-remodal-action="close" class="remodal-close"></span>
<h1>Remodal</h1>
<p>
Flat, responsive, lightweight, fast, easy customizable modal window plugin
Expand All @@ -89,8 +90,8 @@ <h1>Remodal</h1>
Minified version size: ~4kb
</p>
<br>
<a class="remodal-cancel" href="#">Cancel</a>
<a class="remodal-confirm" href="#">OK</a>
<a data-remodal-action="cancel" class="remodal-cancel" href="#">Cancel</a>
<a data-remodal-action="confirm" class="remodal-confirm" href="#">OK</a>
</div>

<div data-remodal-id="modal2">
Expand All @@ -99,7 +100,7 @@ <h1>Another one window</h1>
Hello!
</p>
<br>
<a class="remodal-confirm" href="#">Hello!</a>
<a data-remodal-action="confirm" class="remodal-confirm" href="#">Hello!</a>
</div>

<!-- You can define the global options -->
Expand Down
7 changes: 4 additions & 3 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h1>Remodal</h1>
</div>

<div class="remodal" data-remodal-id="modal">
<span data-remodal-action="close" class="remodal-close"></span>
<h1>Remodal</h1>
<p>
Flat, responsive, lightweight, fast, easy customizable modal window plugin
Expand All @@ -89,8 +90,8 @@ <h1>Remodal</h1>
Minified version size: ~4kb
</p>
<br>
<a class="remodal-cancel" href="#">Cancel</a>
<a class="remodal-confirm" href="#">OK</a>
<a data-remodal-action="cancel" class="remodal-cancel" href="#">Cancel</a>
<a data-remodal-action="confirm" class="remodal-confirm" href="#">OK</a>
</div>

<div data-remodal-id="modal2">
Expand All @@ -99,7 +100,7 @@ <h1>Another one window</h1>
Hello!
</p>
<br>
<a class="remodal-confirm" href="#">Hello!</a>
<a data-remodal-action="confirm" class="remodal-confirm" href="#">Hello!</a>
</div>

<!-- You can define the global options -->
Expand Down
2 changes: 0 additions & 2 deletions src/jquery.remodal.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import url(//fonts.googleapis.com/css?family=Exo+2:700,400&subset=latin,cyrillic);

/* ==========================================================================
Remodal necessary styles
========================================================================== */
Expand Down
8 changes: 5 additions & 3 deletions src/jquery.remodal.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
}

remodal.$bg = $('.' + namespace + '-bg');
remodal.$closeButton = $('<a href="#"></a>').addClass(namespace + '-close');

remodal.$wrapper = $('<div>').addClass(namespace + '-wrapper');
remodal.$modal = $modal;
remodal.$modal.addClass(namespace);
Expand All @@ -243,8 +243,10 @@
remodal.$modal.append(remodal.$closeButton);
remodal.$wrapper.append(remodal.$modal);
remodal.$body.append(remodal.$wrapper);
remodal.$confirmButton = remodal.$modal.find('.' + namespace + '-confirm');
remodal.$cancelButton = remodal.$modal.find('.' + namespace + '-cancel');

remodal.$closeButton = remodal.$modal.find('[data-' + namespace + '-action="close"]');
remodal.$confirmButton = remodal.$modal.find('[data-' + namespace + '-action="confirm"]');
remodal.$cancelButton = remodal.$modal.find('[data-' + namespace + '-action="cancel"]');

// Calculate timeouts
tdOverlay = getTransitionDuration(remodal.$overlay);
Expand Down
12 changes: 8 additions & 4 deletions test/remodal.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@

<a href="#" data-remodal-target="modal">Call</a>
<div class="remodal" data-remodal-id="modal">
<a class="remodal-cancel" href="#">Cancel</a>
<a class="remodal-confirm" href="#">OK</a>
<a data-remodal-action="close" class="remodal-close"></a>

<a data-remodal-action="cancel" class="remodal-cancel" href="#">Cancel</a>
<a data-remodal-action="confirm" class="remodal-confirm" href="#">OK</a>
</div>

<div class="remodal" data-remodal-id="modal2" data-remodal-options="hashTracking: false,closeOnConfirm:false,closeOnCancel: false">
<a class="remodal-cancel" href="#">Cancel</a>
<a class="remodal-confirm" href="#">OK</a>
<a data-remodal-action="close" class="remodal-close"></a>
<a data-remodal-action="cancel" class="remodal-cancel" href="#">Cancel</a>
<a data-remodal-action="confirm" class="remodal-confirm" href="#">OK</a>
</div>

<div data-remodal-id="modal3">
<a data-remodal-action="close" class="remodal-close"></a>
</div>
</body>
</html>

0 comments on commit de6ffe6

Please sign in to comment.