Skip to content

Commit

Permalink
Fix duplicate graphs in Turbolinks previews
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidka committed Aug 7, 2017
1 parent 7e3e7c4 commit 9237739
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/views/devices/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ can_edit_parameters = can?(:update, 'devices/parameters')
content_for :title do 'Device ' + @device['_id'] end
%>
<script type="text/javascript">
var pending = {};

$(function() {
clearPending();

var options = {
valueNames: ['param-path', 'param-value'],
page: 4000
};

var featureList = new List('device-params', options);
refreshPending();
});
</script>

Expand Down
4 changes: 4 additions & 0 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ content_for :title do 'Home' end
<% end %>
<script type="text/javascript">
$(function() {
// Skip if Turbolinks preview
if (document.documentElement.hasAttribute("data-turbolinks-preview"))
return;

<% @graphs.each do |group_name, group_graphs| %>
<% group_graphs.each do |graph_name, graph| %>
pieChart("<%= group_name %>_<%= graph_name %>", 200, <%= ActiveSupport::JSON.encode(graph).html_safe %>);
Expand Down
8 changes: 7 additions & 1 deletion app/views/provisions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
<% end %>

<script type="text/javascript">
CodeMirror.fromTextArea(document.getElementById('script'), {mode: 'javascript', lineNumbers: true});
$(function() {
// Skip if Turbolinks previewلا
if (document.documentElement.hasAttribute("data-turbolinks-preview"))
return;

CodeMirror.fromTextArea(document.getElementById("script"), {mode: "javascript", lineNumbers: true});
});
</script>
8 changes: 7 additions & 1 deletion app/views/virtual_parameters/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
<% end %>

<script type="text/javascript">
CodeMirror.fromTextArea(document.getElementById('script'), {mode: 'javascript', lineNumbers: true});
$(function() {
// Skip if Turbolinks preview
if (document.documentElement.hasAttribute("data-turbolinks-preview"))
return;

CodeMirror.fromTextArea(document.getElementById("script"), {mode: "javascript", lineNumbers: true});
});
</script>

0 comments on commit 9237739

Please sign in to comment.