mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 06:56:54 +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;
|
||||
}
|
||||
|
||||
$(document).on('page:before-change', beforechange);
|
||||
$(window).on('beforeunload', beforeunload);
|
||||
$(window).on("beforeunload", function() {
|
||||
$(window).off('beforeunload');
|
||||
$(document).off('page:before-change');
|
||||
return alertText;
|
||||
});
|
||||
|
||||
function beforeunload() {
|
||||
//Check if we are actually in report editor
|
||||
if ( $(REPORT_CONTENT).length ) {
|
||||
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);
|
||||
$(document).on("page:before-change", function() {
|
||||
var exit;
|
||||
exit = confirm(alertText);
|
||||
if ( exit ) {
|
||||
// We leave the page so remove all listeners
|
||||
$(window).off('beforeunload');
|
||||
$(document).off('page:before-change');
|
||||
}
|
||||
}
|
||||
|
||||
function beforechange() {
|
||||
//Check if we are actually in report editor
|
||||
if ( $(REPORT_CONTENT).length ) {
|
||||
var exit;
|
||||
exit = confirm(alertText);
|
||||
if ( exit ) {
|
||||
// We leave the page so remove all listeners
|
||||
$(window).off();
|
||||
$(document).off();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
return exit;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
data-reports-click-new-report-step-text="<%=t 'tutorial.reports_index_click_new_report_html' %>">
|
||||
<div>
|
||||
<% 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="hidden-xs"><%=t "projects.reports.index.new" %></span>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue