Sha256: 3557e6206da28453d919422af5a88c295be42f9786a89ac201db61f61c795f6b

Contents?: true

Size: 1023 Bytes

Versions: 65

Compression:

Stored size: 1023 Bytes

Contents

class TabbedForm {
  /**
   * Bootstrap Tabs use anchors to identify tabs. Anchor of active tab is added as hidden input to given form 
   * so that active tab state can be maintained after Post.
   * @param {form} form element that includes tabs and to which tab anchor will be added as an input
   */
  constructor(form) {
    this.form = form;
  }

  setup() {
    this.refererAnchor = this.addRefererAnchor()
    this.watchActiveTab()
    this.setRefererAnchor($('.nav-tabs li.active a').attr('href'))
  }

  addRefererAnchor() {
    let referer_anchor_input = $('<input>').attr({type: 'hidden', id: 'referer_anchor', name: 'referer_anchor'}) 
    this.form.append(referer_anchor_input)
    return referer_anchor_input
  }

  setRefererAnchor(id) {
    this.refererAnchor.val(id)
  }

  watchActiveTab() {
    $('.nav-tabs a').on('shown.bs.tab', (e) => this.setRefererAnchor($(e.target).attr('href')))
  }
}

export default function tabifyForm(form) {
  let formTabifier = new TabbedForm(form)
  formTabifier.setup()
}

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.4 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.3 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.2 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.1 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.0 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-3.6.0 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-4.0.0 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-3.5.0 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-3.4.2 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-3.4.1 app/assets/javascripts/hyrax/tabbed_form.es6
hyrax-3.4.0 app/assets/javascripts/hyrax/tabbed_form.es6