TMP start transitioning to bootstrap modals

This commit is contained in:
Gergely Polonkai 2015-10-05 15:48:15 +02:00
parent cf888b7247
commit d2e1bcccec

View File

@ -25,11 +25,13 @@
border: 0 none; border: 0 none;
} }
</style> </style>
<link rel="stylesheet" href="js/fancybox/source/jquery.fancybox.css" type="text/css"> <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="js/jquery-2.1.1.min.js"></script>
<script src="js/fancybox/source/jquery.fancybox.pack.js"></script> <script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head> </head>
<body> <body>
<div class="container">
<select> <select>
<option value="">Mind / All</option> <option value="">Mind / All</option>
<option value="aries">Kos / Aries</option> <option value="aries">Kos / Aries</option>
@ -62,7 +64,7 @@
<option value="pisces">Halak / Pisces</option> <option value="pisces">Halak / Pisces</option>
</select> </select>
<button id="draw">Húzz egyet / Draw one</button> <button type="button" class="btn" data-toggle="modal" data-target="#draw-one-modal" id="draw">Húzz egyet!</button>
<hr> <hr>
@ -70,18 +72,42 @@
{% assign list = site.data.symbolon | sort:'number'%} {% assign list = site.data.symbolon | sort:'number'%}
{% for s in list %} {% for s in list %}
{% assign image = '0' | append: s.number %} {% assign image = '0' | append: s.number %}
{% comment %}
Using image|slice:-2,2 would be much easier here. However, it seems the
slice filer is not working for some time now…
{% endcomment %}
{% assign len = image | size %} {% assign len = image | size %}
{% if len == 3 %} {% if len == 3 %}
{% assign image = '' | append: s.number %} {% assign image = '' | append: s.number %}
{% endif %} {% endif %}
<div class="card{% for sign in s.signs %} {{sign}}{% endfor %}"> <div class="card{% for sign in s.signs %} {{sign}}{% endfor %}">
<a id="card_{{image}}" class="fancybox" rel="group" href="images/{{image}}.jpg"> <a id="card_{{image}}" rel="group" href="images/{{image}}.jpg">
<img src="images/{{image}}.jpg" alt="{{s.name}}"> <img src="images/{{image}}.jpg" alt="{{s.name}}">
</a> </a>
<p class="cim">{{s.number}}. {{s.name}}</p> <p class="cim">{{s.number}}. {{s.name}}</p>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div>
<div class="modal fade" id="draw-one-modal" tabindex="-1" role="dialog" aria-labelledby="draw-one-title">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="draw-one-title">Draw One</h4>
</div>
<div class="modal-body" id="draw-one-body">
Body!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script> <script>
$('select').change(function () { $('select').change(function () {
@ -91,7 +117,6 @@
$('select').each(function (i, e) { $('select').each(function (i, e) {
sign = $(e).val(); sign = $(e).val();
if (sign != '') { if (sign != '') {
classes.push($(e).val()); classes.push($(e).val());
} }
@ -115,9 +140,8 @@
selector = '.' + classes[0] + '[class="card ' + classes[0] + '"]'; selector = '.' + classes[0] + '[class="card ' + classes[0] + '"]';
} }
console.log(selector);
$('div.card').show(); $('div.card').show();
if (selector != '') { if (selector != '') {
$('div.card').not(selector).hide(); $('div.card').not(selector).hide();
} }
@ -126,35 +150,25 @@
function resize_holder() { function resize_holder() {
var winheight = $(window).height(); var winheight = $(window).height();
var holdertop = $('#holder').position().top; var holdertop = $('#holder').position().top;
$('#holder').height(winheight - holdertop - 10); $('#holder').height(winheight - holdertop - 10);
} }
$(document).ready(function () { $(document).ready(function () {
resize_holder(); resize_holder();
$('.fancybox').fancybox({
beforeShow: function() {
var alt = this.element.find('img').attr('alt');
this.inner.find('img').attr('alt', alt);
this.title = alt;
}
});
}); });
$(window).resize(function () { $(window).resize(function () {
resize_holder(); resize_holder();
}); });
$('#draw').click(function () { $('#draw-one-modal').on('show.bs.modal', function(e) {
count = $('div.card').length; count = $('div.card').length;
draw_num = Math.floor(Math.random() * count) + 1; draw_num = Math.floor(Math.random() * count) + 1;
num_str = (draw_num < 10) ? '0' + draw_num : draw_num; num_str = (draw_num < 10) ? '0' + draw_num : draw_num;
draw_id = '#card_' + num_str;
console.log(draw_id); $('#draw-one-body').html('');
$(draw_id).click();
}); });
</script> </script>
</body> </body>