]> git.0d.be Git - panikweb.git/commitdiff
factorize gallery js
authorFrédéric Péters <fpeters@0d.be>
Sun, 31 May 2015 13:46:19 +0000 (15:46 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sun, 31 May 2015 13:46:19 +0000 (15:46 +0200)
panikweb_templates/static/js/specifics.js
panikweb_templates/templates/combo/gallery.html

index d73468932b5c9cabd76be71453c60bdbbd9dddba..6409f200ea07217ce93bbdb18e40077b2c0b7588 100644 (file)
@@ -531,4 +531,15 @@ $(function() {
                });
                $waveform.find('span.done:last').addClass('current');
        });
+
+       $('.gallery').each(function() {
+         var $gallery = $(this);
+         $gallery.find('span').on('click', function() {
+           $gallery.find('div.first img').attr('src', $(this).data('image-large'));
+           $gallery.find('div.first').show('fade');
+           return false;
+         });
+         $gallery.find('div.first').on('click', function() { $(this).toggle('fade'); return false; });
+       });
+
 });
index b3c6bb983eec196a8c9a53f7bfe709747f076977..c1c179b181274704b44014854686a958d4eb4768 100644 (file)
@@ -3,12 +3,10 @@
 <div class="gallery" id="gallery-{{cell.id}}">
 {% for image in cell.image_set.all %}
   {% if forloop.first %}
-{% thumbnail image.image "640x480" crop="50% 25%" as im %}
 <div class="first" style="display: none;">
-<img src="{{ im.url }}"/>
+<img src="#"/>
 </div>
 <div>
-{% endthumbnail %}
   {% endif %}
 {% thumbnail image.image "200x100" crop="50% 25%" as im %}
 {% thumbnail image.image "640x480" crop="50% 25%" as im_large %}
 {% endfor %}
 </div>
 </div>
-<script type="text/javascript">
-$(function() {
-  var $gallery = $('#gallery-{{cell.id}}');
-  $gallery.find('span').on('click', function() {
-    $gallery.find('div.first img').attr('src', $(this).data('image-large'));
-    $gallery.find('div.first').show('fade');
-  });
-  $gallery.find('div.first').on('click', function() {
-    $(this).toggle('fade');
-  });
-});
-</script>