Sha256: e6eca015a232a268bbb871ad9f9767039157a25934433aae4fc91edf8e49a9d8

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require("jquery")
console.log("loading common core...")

$(function(){
  // always pass csrf tokens on ajax calls
  $.ajaxSetup({
    headers: { 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') }
  });
});

$(document).on('turbolinks:load', function() {
  $(document).ready(() => {
    $("body").on("click", "[data-role='close-button']", (event) => {
      var form_name;
      form_name = $(event.currentTarget).data("name");
      row_id = $(event.currentTarget).data("row-id");

      if (row_id) {
        $("table." + form_name + "-table tr[data-id=" + row_id + "][data-edit='true']").remove()
        $("table." + form_name + "-table tr[data-id=" + row_id + "]:not([data-edit='true'])").fadeIn()
        $("table." + form_name + "-table tr[data-id=" + row_id + "]:not([data-edit='true']) .show-area").show()
      } else {
        if ($(".new-" + form_name + "-form").length == 0) {
          throw("ERROR: not found" + "  .new-" + form_name + "-form")
        }
        var $form = $(event.currentTarget).closest(".new-" + form_name + "-form")
        $form.slideUp()
        $form.siblings(".new-" + form_name + "-button").fadeIn()
        $form.find("i").remove()
      }
    })
  })
});



Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
common_core_js-0.3.2 lib/generators/common_core/templates/common_core.js
common_core_js-0.3.1 lib/generators/common_core/templates/common_core.js