mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 15:05:26 +08:00
Merge pull request #204 from okriuchykhin/ok_SCI-463
Fix issue with pop-up windows and turbolinks [SCI-463]
This commit is contained in:
commit
076353b207
2 changed files with 15 additions and 30 deletions
|
@ -443,37 +443,22 @@ function initializeUnsavedWorkDialog() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('page:before-change', beforechange);
|
$(window).on("beforeunload", function() {
|
||||||
$(window).on('beforeunload', beforeunload);
|
$(window).off('beforeunload');
|
||||||
|
$(document).off('page:before-change');
|
||||||
function beforeunload() {
|
|
||||||
//Check if we are actually in report editor
|
|
||||||
if ( $(REPORT_CONTENT).length ) {
|
|
||||||
return alertText;
|
return alertText;
|
||||||
} else {
|
});
|
||||||
// We are at another page so remove unload handlers if they exists
|
|
||||||
$(window).off('beforeunload', beforeunload);
|
|
||||||
$(document).off('page:before-change', beforechange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function beforechange() {
|
$(document).on("page:before-change", function() {
|
||||||
//Check if we are actually in report editor
|
|
||||||
if ( $(REPORT_CONTENT).length ) {
|
|
||||||
var exit;
|
var exit;
|
||||||
exit = confirm(alertText);
|
exit = confirm(alertText);
|
||||||
if ( exit ) {
|
if ( exit ) {
|
||||||
// We leave the page so remove all listeners
|
// We leave the page so remove all listeners
|
||||||
$(window).off();
|
$(window).off('beforeunload');
|
||||||
$(document).off();
|
$(document).off('page:before-change');
|
||||||
}
|
}
|
||||||
return exit;
|
return exit;
|
||||||
} else {
|
});
|
||||||
// We are at another page so remove unload handlers if they exists
|
|
||||||
$(window).off('beforeunload', beforeunload);
|
|
||||||
$(document).off('page:before-change', beforechange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
data-reports-click-new-report-step-text="<%=t 'tutorial.reports_index_click_new_report_html' %>">
|
data-reports-click-new-report-step-text="<%=t 'tutorial.reports_index_click_new_report_html' %>">
|
||||||
<div>
|
<div>
|
||||||
<% if can_create_new_report(@project) %>
|
<% if can_create_new_report(@project) %>
|
||||||
<%= link_to new_project_reports_path(@project), class: "btn btn-primary", id: "new-report-btn" do %>
|
<%= link_to new_project_reports_path(@project), class: 'btn btn-primary', id: 'new-report-btn', 'data-no-turbolink' => true do %>
|
||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||||
<span class="hidden-xs"><%=t "projects.reports.index.new" %></span>
|
<span class="hidden-xs"><%=t "projects.reports.index.new" %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue