allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/5] allura git commit: [#6299] lightbox on attachments, and make it easier to use
Date Fri, 05 Oct 2018 21:26:05 GMT
[#6299] lightbox on attachments, and make it easier to use


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ca2dc134
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ca2dc134
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ca2dc134

Branch: refs/heads/db/6299
Commit: ca2dc134d4cfe368722e402af00d855092bd47a0
Parents: 5ab6a82
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Oct 5 14:57:18 2018 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Oct 5 17:25:54 2018 -0400

----------------------------------------------------------------------
 Allura/allura/lib/utils.py                           |  2 +-
 Allura/allura/lib/widgets/discuss.py                 | 13 -------------
 Allura/allura/public/nf/js/allura-base.js            | 15 +++++++++++++++
 Allura/allura/templates/widgets/attachment_list.html |  2 +-
 Allura/allura/templates/widgets/post_widget.html     |  7 +------
 .../templates/widgets/project_screenshots.html       |  6 +-----
 6 files changed, 19 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ca2dc134/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index dcf4b79..ccc19d2 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -591,7 +591,7 @@ class ForgeHTMLSanitizerFilter(html5lib.filters.sanitizer.Filter):
         self.allowed_elements = set(html5lib.filters.sanitizer.allowed_elements) - _form_elements
 
         # srcset is used in our own project_list/project_summary widgets which are used as
macros so go through markdown
-        self.allowed_attributes = html5lib.filters.sanitizer.allowed_attributes | {(None,
'srcset'), (None, 'data-src')}
+        self.allowed_attributes = html5lib.filters.sanitizer.allowed_attributes | {(None,
'srcset')}
 
         self.valid_iframe_srcs = ('https://www.youtube.com/embed/', 'https://www.gittip.com/')
         self._prev_token_was_ok_iframe = False

http://git-wip-us.apache.org/repos/asf/allura/blob/ca2dc134/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index ac76da9..b571977 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -417,19 +417,6 @@ class Post(HierWidget):
                     });
                 }
             });
-
-            //lightbox_me script to create lightbox of attached images
-            $('.lightbox').click(function(e) {
-                var image_source = $(this).data("src");
-                var image = $('#lightbox').find('img:first');
-                image.attr("src", image_source);
-
-                $('#lightbox').lightbox_me({
-                    centered: true
-                });
-
-                e.preventDefault();
-            });
         }());
         ''')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/ca2dc134/Allura/allura/public/nf/js/allura-base.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/allura-base.js b/Allura/allura/public/nf/js/allura-base.js
index e03f065..f7b8a3c 100644
--- a/Allura/allura/public/nf/js/allura-base.js
+++ b/Allura/allura/public/nf/js/allura-base.js
@@ -216,4 +216,19 @@ $(function(){
 
     twemoji.size = '36x36';
     twemoji.parse($('#content_base')[0]);
+
+    $('.lightbox').click(function(e) {
+        var image_source = $(this).data("src") || $(this).attr('href');
+        if ($('#lightbox').length === 0) {
+            $('body').append('<div id="lightbox" style="display:none; height: 90%"><img
style="display: block; max-height: 100%; max-width: 100%; margin-left: auto; margin-right:
auto;"></div>');
+        }
+        var image = $('#lightbox').find('img:first');
+        image.attr("src", image_source);
+
+        $('#lightbox').lightbox_me({
+            centered: true
+        });
+
+        e.preventDefault();
+    });
 });

http://git-wip-us.apache.org/repos/asf/allura/blob/ca2dc134/Allura/allura/templates/widgets/attachment_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/attachment_list.html b/Allura/allura/templates/widgets/attachment_list.html
index f924b42..1bedec0 100644
--- a/Allura/allura/templates/widgets/attachment_list.html
+++ b/Allura/allura/templates/widgets/attachment_list.html
@@ -24,7 +24,7 @@
     <div class="attachment_images">
       {% for att in attachments if att.is_image() %}
           <div class="attachment_thumb">
-            <a href="{{att.url()}}">
+            <a href="{{att.url()}}" class="lightbox">
               <img src="{{att.url()}}/thumb" alt="Thumbnail"/>
             <br/>
             {{att.filename}}

http://git-wip-us.apache.org/repos/asf/allura/blob/ca2dc134/Allura/allura/templates/widgets/post_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html
index f98aafa..4439821 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -101,7 +101,7 @@
             <div class="attachment_item">
                 {% if att.is_image() %}
                     <div class="attachment_thumbnail">
-                        <a class="lightbox" data-src="{{att.url()}}" href="{{att.url()}}">
+                        <a class="lightbox" href="{{att.url()}}">
                             <img src="{{att.url()}}/thumb" alt="Thumbnail"/>
                         </a>
                     </div>
@@ -168,9 +168,4 @@
       </li>
     </ul>
   </div>
-    <!-- lightbox_me div that will dynamically load attachment image -->
-  <div id="lightbox" style="display:none; height: 90%">
-      <img style="width: inherit; height: inherit; display: block; margin-left: auto;
margin-right: auto;">
-  </div>
-
 </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/ca2dc134/Allura/allura/templates/widgets/project_screenshots.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/project_screenshots.html b/Allura/allura/templates/widgets/project_screenshots.html
index 83bbbc1..5aa5059 100644
--- a/Allura/allura/templates/widgets/project_screenshots.html
+++ b/Allura/allura/templates/widgets/project_screenshots.html
@@ -25,7 +25,7 @@
   {% for ss in screenshots %}
   <div data-ss-id="{{ ss._id }}" class="screenshot">
     <div class="image">
-      <a class="lightbox" data-src="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}"
href="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}" ><img src="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}/thumb"
alt="Screenshot thumbnail"/></a>
+      <a class="lightbox" href="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}"
><img src="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}/thumb" alt="Screenshot
thumbnail"/></a>
       {% if not edit %}
       <br>
       {{ss.caption}}
@@ -50,7 +50,3 @@
   {% endfor %}
 </div>
 {% if screenshots.__len__() %}<hr>{% endif %}
-<!-- lightbox_me div that will dynamically load attachment image -->
-<div id="lightbox" style="display:none; height: 90%">
-  <img style="width: inherit; height: inherit; display: block; margin-left: auto; margin-right:
auto;">
-</div>
\ No newline at end of file


Mime
View raw message