-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lazy load images using lazyload-rails gem
- Loading branch information
1 parent
f4dfdcb
commit ab08fe9
Showing
13 changed files
with
72 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
<div class="col-lg-6 note-container-question"> | ||
<div class="note note-pane note-question<% if node.status == 4 %> moderated<% end %>"> | ||
|
||
<div class="header-icon"><i class="fa fa-question-circle"></i> <a href="/q/<%= node.id %>"><i class="fa fa-link"></i></a></div> | ||
|
||
<div style="overflow: hidden;"> | ||
|
||
<%= render partial: 'dashboard/node_moderate', locals: { node: node } %> | ||
<% if node.main_image %> | ||
<a class="img" href="<%= node.path(:question) %>"><img src="<%= node.main_image.path(:default) %>" style="width:100%;" /></a> | ||
<a class="img" href="<%= node.path(:question) %>"><%= image_tag(node.main_image.path(:default), style:'width:100%;') %></a> | ||
<% elsif node.scraped_image %> | ||
<a class="img" href="<%= node.path %>"><img src="<%= node.scraped_image %>" style="width:100%;" /></a> | ||
<a class="img" href="<%= node.path %>"><%= image_tag(node.scraped_image, style:'width:100%;') %></a> | ||
<% end %> | ||
|
||
<h4><a href="<%= node.path(:question) %>"><%= node.title %></a></h4> | ||
|
||
<p class="meta"><%= translation('dashboard._node_question.question') %> <%= render partial: "dashboard/node_meta", locals: { node: node } %></p> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
$(function(){ | ||
$("img").lazyload(); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
<%= render :partial => "map/leaflet" , locals: { lat: @map_lat, lon: @map_lon, zoom: @map_zoom, blurred: @map_blurred, topmap: true, user: @profile_user } %> | ||
<% elsif !current_user.nil? && current_user.id == @profile_user.id %> | ||
<div id="map_template" style="position: relative; width: 100%; display: inline-block;"> | ||
<img src="https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/0/0/0.png" style="height:300px; width: 100%; margin: 0; position: relative; margin-right: -10px;"> | ||
<img src="https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/0/0/0.png" style="height:300px; width: 100%; margin: 0; position: relative; margin-right: -10px;"> | ||
<button type='button' class='blurred-location-input btn btn-default btn-lg' onclick='addLocation()' style="position: absolute; position: absolute;top: 41% ; left: 15% ;"> <strong> Share your Location </strong> </button> | ||
<p><i><small>Learn about <a href='https://publiclab.org/wiki/location-privacy'>privacy</a> </small></i></p> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<br /> | ||
|
@@ -45,14 +45,14 @@ | |
|
||
<div class="offset-md-1 order-first order-md-last col-md-4 text-center"> | ||
<div class="text-center"> | ||
<%if @content_approved or (!current_user.nil? && current_user.id == @profile_user.id)%> | ||
<img class="d-none d-lg-inline rounded-circle" id="profile-photo" style="width:50%;margin-bottom:10px;" src="<%= @profile_user.profile_image %>" /> | ||
<%if @content_approved or (!current_user.nil? && current_user.id == @profile_user.id)%> | ||
<%= image_tag(@profile_user.profile_image, class:'d-none d-lg-inline rounded-circle', id:'profile-photo', style:"width:50%;margin-bottom:10px;") %> | ||
<%end%> | ||
<h4 class="mt-3"><strong>@<%= @profile_user.name %> <%= @profile_user.new_contributor %></strong></h4> | ||
</div> | ||
<div style="text-align:center;" class="d-lg-none"> | ||
<%if @content_approved or (!current_user.nil? && current_user.id == @profile_user.id)%> | ||
<img class="rounded-circle" id="profile-photo" style="width:50%;margin-bottom:20px;" src="<%= @profile_user.profile_image(:medium) %>" /> | ||
<%if @content_approved or (!current_user.nil? && current_user.id == @profile_user.id)%> | ||
<%= image_tag(@profile_user.profile_image(:medium), class:'rounded-circle', id:'profile-photo', style:"width:50%;margin-bottom:20px;") %> | ||
<%end%> | ||
<h4 class="mt-3"><strong>@<%= @profile_user.name %> <%= @profile_user.new_contributor %></strong></h4> | ||
</div> | ||
|
@@ -66,9 +66,9 @@ | |
<% if @profile_user.status == 0 %> | <i class="fa fa-ban" style="color:#a00;"></i> <%= translation('users.profile.banned') %><% end %> | ||
</small> | ||
</h4> | ||
<%if @content_approved or (!current_user.nil? && current_user.id == @profile_user.id)%> | ||
<%if @content_approved or (!current_user.nil? && current_user.id == @profile_user.id)%> | ||
<p><%= raw auto_link(RDiscount.new(@profile_user.bio || '').to_html, :sanitize => false) %></p> | ||
<%end%> | ||
<%end%> | ||
<div class="mt-3"> | ||
|
||
<a class="btn btn-outline-secondary" id="tags-section">Tags</a> | ||
|
@@ -273,6 +273,9 @@ | |
<script src = "https://cdn.jsdelivr.net/npm/[email protected]/dist/frappe-charts.min.iife.js"></script> | ||
|
||
<script type = "text/javascript"> | ||
$(function(){ | ||
$("img").lazyload(); | ||
}); | ||
//Upon clicking copy button, copyToken function is activated. | ||
$('#copy-btn').on('click', copyToken); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Lazyload::Rails.configure do |config| | ||
# By default, a 1x1 grey gif is used as placeholder ("data:image/gif;base64,..."). | ||
# This can be easily customized: | ||
# config.placeholder = "/public/img/grey.gif" | ||
|
||
# image_tag can return lazyload-friendly images by default, | ||
# no need to pass the { lazy: true } option | ||
config.lazy_by_default = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters