(function() {
  var $, hepfr_base_fade_contact_list, hepfr_base_lock_root_menu, hepfr_base_set_filter_label_visibility, hepfr_base_set_views_filter_widget, hepfr_base_toolbar_block_search, hepfr_webform_clear_file_input;
  $ = jQuery;
  if (typeof CKEDITOR === "object") {
    CKEDITOR.on('dialogDefinition', function(ev) {
      var dialogDefinition, dialogName, infoTab;
      dialogName = ev.data.name;
      dialogDefinition = ev.data.definition;
      if (dialogName === 'link') {
        dialogDefinition.removeContents('advanced');
        return infoTab = dialogDefinition.getContents('info');
      }
    });
  }
  hepfr_base_set_filter_label_visibility = function($label, $input) {
    if ($.trim($input.val()) !== "") {
      return $label.hide();
    } else {
      return $label.show();
    }
  };
  hepfr_base_fade_contact_list = function() {
    return $(".view-contact-list table").css({
      opacity: 0.5
    });
  };
  hepfr_base_toolbar_block_search = function(context) {
    return $("#page-top-nav:not(.h-processed)", context).each(function(el) {
      var $content, $this;
      $this = $(this);
      $this.addClass('h-processed');
      $content = $("#block-search-form .content", $this).css({
        width: "1px"
      });
      $("#block-search-form", $this).append('<div class="toggle">Toggle search</div>');
      return $(".toggle", $this).click(function(e) {
        var $bt;
        $bt = $(this);
        if ($content.innerWidth() > 5) {
          $content.animate({
            width: '1px'
          }, 200);
        } else {
          $content.animate({
            width: '236px'
          }, 200);
        }
        return $bt.toggleClass('toggle-close');
      });
    });
  };
  hepfr_webform_clear_file_input = function(context) {
    return $(".webform-component-file:not(.h-processed)", $(context)).each(function(el) {
      var $this;
      $this = $(this);
      $this.addClass("h-processed");
      $this.append("<div><a href='#' class='file_remove'>" + Drupal.t("Remove file") + "</a></div>");
      return $(".file_remove", $this).click(function(e) {
        var o;
        e.preventDefault();
        o = $(".form-file", $this);
        return o.replaceWith("<input id='" + o.attr("id") + "' class='" + o.attr("class") + "' size='" + o.attr("size") + "' type='" + o.attr("type") + "' name='" + o.attr("name") + "' />");
      });
    });
  };
  hepfr_base_lock_root_menu = function(context) {
    return $(".node-form:not(.h-processed)", $(context)).each(function(el) {
      var $this;
      $this = $(this);
      $this.addClass("h-processed");
      return $(".form-actions .form-submit").click(function(e) {
        if ($("#edit-menu-enabled:checked", context).size() === 1) {
          if ($("#edit-menu-parent").val() === "main-menu:0") {
            if (Drupal.settings.hepfr_f_base.enabled === "TRUE") {
              e.preventDefault();
              return $("#ajax-menu-parent a").click();
            }
          }
        }
      });
    });
  };
  hepfr_base_set_views_filter_widget = function(el, $form) {
    var $input, $label, $submit, $this;
    $this = $(el);
    $this.addClass("h-processed");
    $label = $("label", $this);
    $input = $("input", $this);
    $submit = $(".views-submit-button input");
    $form.submit(function(e) {
      return hepfr_base_fade_contact_list();
    });
    $submit.click(function(e) {
      return hepfr_base_fade_contact_list();
    });
    $input.keydown(function(e) {
      if (e.keyCode === 13) {
        e.preventDefault();
        return $submit.click();
      }
    });
    hepfr_base_set_filter_label_visibility($label, $input);
    $input.blur(function(e) {
      return hepfr_base_set_filter_label_visibility($label, $input);
    });
    $input.click(function(e) {
      return $label.hide();
    });
    return $input.focus(function(e) {
      return $label.hide();
    });
  };
  Drupal.behaviors.hepfr_base = {
    attach: function(context, settings) {
      hepfr_webform_clear_file_input(context);
      hepfr_base_toolbar_block_search(context);
      hepfr_base_lock_root_menu(context);
      $(".view-contact-list table").css({
        opacity: 1,
        filter: ''
      });
      $(".views-widget-filter-keys:not(.h-processed)", context).each(function(el) {
        return hepfr_base_set_views_filter_widget(this, $("#views-exposed-form-publications-list-block"));
      });
      return $(".views-widget-filter-title:not(.h-processed)", context).each(function(el) {
        return hepfr_base_set_views_filter_widget(this, $("#views-exposed-form-contact-list-block"));
      });
    }
  };
}).call(this);
;

