{:uriI"�file:///Users/tyler/Development/GitHub/guts/app/assets/javascripts/guts/navigation.js?type=application/javascript&pipeline=self&id=59f4cbd0104b1947ff2c1b765cef63122d33707073ff3048fa84fa58c583c6c3:ET:load_pathI"@/Users/tyler/Development/GitHub/guts/app/assets/javascripts;T:
filenameI"S/Users/tyler/Development/GitHub/guts/app/assets/javascripts/guts/navigation.js;T:	nameI"guts/navigation;T:logical_pathI"guts/navigation.self.js;T:content_typeI"application/javascript;T:sourceI"jQuery(document).ready(function($) {
  if ($("body").attr("id").indexOf("guts_navigation_items") == -1) { return; }
  
  $(window).on("load", function() {
    if ($("body").attr("id").indexOf("guts_navigation_items_edit") == -1) { return; }
    
    // Trigger change for edit to run
    $("#navigation_item_navigatable_type").trigger("change");
  });
  
  $("#navigation_item_navigatable_type").on("change", function() {
    var value = $(this).val();
    if (value === "") {
      // Show custom entry
      $("#navigation_item_navigatable_id").html("").hide();
      $("#navigation_item_custom").show();
    } else {
      // Show dynamic navigatable entries
      $("#navigation_item_navigatable_id").html("").show();
      $("#navigation_item_custom").hide();

      $.ajax({
        url: $(this).data("callback-url"),
        data: {model: $(this).val()},
        dataType: "json",
      }).done(function(data) {
        $.each(data, function() {
          // Populate the navigatable objects
          $("#navigation_item_navigatable_id").append('<option value="'+this.id+'">'+this.format+'</option>');
        });
        
        var initial = $("#navigation_item_navigatable_id").data("initial");
        if (initial) {
          // Edit screen, re-select the initial after the AJAX call
          $("#navigation_item_navigatable_id option").each(function() {
            if ($(this).val() == initial) {
              $("#navigation_item_navigatable_id").val($(this).val()).trigger("change");
            }
          });
        }
      });
    }
  });
});
;T:
metadata{:dependencieso:Set:
@hash{
I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"afile-digest:///Users/tyler/Development/GitHub/guts/app/assets/javascripts/guts/navigation.js;TT:
requiredo;;{�:stubbedo;;{�:
linkso;;{�:charsetI"
utf-8;F:digest"% ��@�����^�����y�iau���3�:lengthi:dependencies_digest"%.,�T>z��8�e����o��i�k�5N��^�w�4:idI"E59f4cbd0104b1947ff2c1b765cef63122d33707073ff3048fa84fa58c583c6c3;F:
mtimel+��V