search_api.admin.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copied from filter.admin.js
  2. (function ($) {
  3. Drupal.behaviors.searchApiStatus = {
  4. attach: function (context, settings) {
  5. $('.search-api-status-wrapper input.form-checkbox', context).once('search-api-status', function () {
  6. var $checkbox = $(this);
  7. // Retrieve the tabledrag row belonging to this processor.
  8. var $row = $('#' + $checkbox.attr('id').replace(/-status$/, '-weight'), context).closest('tr');
  9. // Retrieve the vertical tab belonging to this processor.
  10. var $tab = $('#' + $checkbox.attr('id').replace(/-status$/, '-settings'), context).data('verticalTab');
  11. // Bind click handler to this checkbox to conditionally show and hide the
  12. // filter's tableDrag row and vertical tab pane.
  13. $checkbox.bind('click.searchApiUpdate', function () {
  14. if ($checkbox.is(':checked')) {
  15. $row.show();
  16. if ($tab) {
  17. $tab.tabShow().updateSummary();
  18. }
  19. }
  20. else {
  21. $row.hide();
  22. if ($tab) {
  23. $tab.tabHide().updateSummary();
  24. }
  25. }
  26. // Restripe table after toggling visibility of table row.
  27. Drupal.tableDrag['search-api-' + $checkbox.attr('id').replace(/^edit-([^-]+)-.*$/, '$1') + '-order-table'].restripeTable();
  28. });
  29. // Attach summary for configurable items (only for screen-readers).
  30. if ($tab) {
  31. $tab.fieldset.drupalSetSummary(function (tabContext) {
  32. return $checkbox.is(':checked') ? Drupal.t('Enabled') : Drupal.t('Disabled');
  33. });
  34. }
  35. // Trigger our bound click handler to update elements to initial state.
  36. $checkbox.triggerHandler('click.searchApiUpdate');
  37. });
  38. }
  39. };
  40. Drupal.behaviors.searchApiEditMenu = {
  41. attach: function (context, settings) {
  42. $('.search-api-edit-menu-toggle', context).click(function (e) {
  43. $menu = $(this).parent().find('.search-api-edit-menu');
  44. if ($menu.is('.collapsed')) {
  45. $menu.removeClass('collapsed');
  46. }
  47. else {
  48. $menu.addClass('collapsed');
  49. }
  50. return false;
  51. });
  52. }
  53. };
  54. })(jQuery);