Skip to content

Commit

Permalink
Remove all code that relies on onbeforeunload but keep Angulor's st…
Browse files Browse the repository at this point in the history
…ate change detection
  • Loading branch information
wielinde committed Apr 13, 2017
1 parent e680639 commit c13ef9f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 80 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
//= require top-shelf
//= require unsupported-browsers
//= require autocomplete_textareas
//= require warn_leaving_unsaved
//= require openproject_plugins
//= require versions
//= require_tree ./specific
Expand Down
54 changes: 0 additions & 54 deletions app/assets/javascripts/warn_leaving_unsaved.js

This file was deleted.

10 changes: 0 additions & 10 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -611,16 +611,6 @@ def user_specific_javascript_includes
I18n.defaultLocale = "#{I18n.default_locale}";
I18n.locale = "#{I18n.locale}";
})
if User.current.pref.warn_on_leaving_unsaved?
tags += javascript_tag(%{
jQuery(document).ready(function(){
warnLeavingUnsaved('#{escape_javascript(l(:text_warn_on_leaving_unsaved))}');
jQuery(document).ajaxComplete(function(){
warnLeavingUnsaved('#{escape_javascript(l(:text_warn_on_leaving_unsaved))}')
});
});
})
end

tags.html_safe
end
Expand Down
15 changes: 0 additions & 15 deletions frontend/app/components/wp-edit/wp-edit-mode-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class WorkPackageEditModeStateService {
protected $q:ng.IQService,
protected I18n:op.I18n) {
const confirmText = I18n.t('js.work_packages.confirm_edit_cancel');
const cancelEventName = 'beforeunload.confirm_cancel';
const requiresConfirmation = ConfigurationService.warnOnLeavingUnsaved();

$rootScope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
Expand All @@ -55,20 +54,6 @@ export class WorkPackageEditModeStateService {
this.cancel();
}
});

// Show confirmation message when browsing to a new page
angular.element($window).on(cancelEventName, (event:JQueryEventObject):string|void => {
if (requiresConfirmation && this.active) {
(event as any).returnValue = confirmText;
event.preventDefault();

return confirmText;
}
});

$rootScope.$on('$destroy', () => {
return angular.element($window).off(cancelEventName);
});
}

public start():boolean {
Expand Down

0 comments on commit c13ef9f

Please sign in to comment.