Sha256: f404624957f9c7bf129c469c3ba77a01480fd527acca0beac193ecb34694bc85

Contents?: true

Size: 1.13 KB

Versions: 32

Compression:

Stored size: 1.13 KB

Contents

// To enable nav safety on a form:
// - Render the shared/nav-safety partial on the page.
// - Add the nav-safety-confirm class to the tab anchor element.
// - Add the nav-safety class to the form element.

Blacklight.onLoad(function() {
  $('.nav-safety-confirm').on('click', function(evt) {
    var dirtyData = $('#nav-safety-modal[dirtyData=true]');
    if (dirtyData.length > 0) {
      evt.preventDefault();
      evt.stopPropagation();
      $('#nav-safety-modal').modal('show');
    }
  });
  
  $('#nav-safety-dismiss').on('click', function(evt) {
    // evt.preventDefault();
    nav_safety_off();
    // $('#nav-safety-change-tab').modal('hide');
  });
  
  $('form.nav-safety').on('change', function(evt) {
    nav_safety_on();
  });
  $('form.nav-safety').on('reset', function(evt) {
    nav_safety_off();
  });
});

function nav_safety_on() {
  $('#nav-safety-modal')[0].setAttribute('dirtyData', true);
}

function nav_safety_off() {
  $('#nav-safety-modal')[0].setAttribute('dirtyData', false);
}

function tinymce_nav_safety(editor) {editor.on('Change', function (e) {
  $(e.target.targetElm).parents('form.nav-safety').change();
});
}

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.9.5 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.9.4 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.9.3 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.9.2 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.9.1 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.9.0 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.8.0 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.7.2 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.7.1 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.7.0 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.6.0 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.5.1 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.5.0 app/assets/javascripts/hyrax/nav_safety.js
hyrax-3.0.0.pre.beta2 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.4.1 app/assets/javascripts/hyrax/nav_safety.js
hyrax-3.0.0.pre.beta1 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.4.0 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.3.3 app/assets/javascripts/hyrax/nav_safety.js
hyrax-2.3.2 app/assets/javascripts/hyrax/nav_safety.js