Skip to content

Commit

Permalink
Merge pull request #38 from backdrop-contrib/patch_search_dialog
Browse files Browse the repository at this point in the history
Fixes #37: search dialog now works as in Drupal
  • Loading branch information
robertgarrigos authored Oct 21, 2024
2 parents 8e3181c + 487914b commit 611d4cf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 45 deletions.
17 changes: 11 additions & 6 deletions js/search-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@
// We can't combine all of these, since that causes
// JQuery.each() to freak ut.'
var selector = null;
if ($('table.views-table').length > 0) {
selector = $('table.views-table tbody tr:not(.views-table-row-select-all)');
// Check for elements matching any of the desired selectors.
if ($('table.views-table', context).length > 0) {
// Use the views-table if found.
selector = $('table.views-table tbody tr:not(.views-table-row-select-all)', context);
}
else if ($('table.views-view-grid').length > 0) {
selector = $('table.views-view-grid td');
else if ($('table.views-view-grid', context).length > 0) {
// Use views-view-grid if found.
selector = $('table.views-view-grid td', context);
}
else if ($('.views-row').length > 0) {
selector = $('.views-row');
else if ($('.views-row', context).length > 0) {
// Use views-row if found.
selector = $('.views-row', context);
}
else {
// If no elements match any of the selectors, exit.
return;
}
selector.each(function(index) {
Expand Down
86 changes: 49 additions & 37 deletions references_dialog.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@
* This the main module file.
*/

/**
* Implements hook_autoload_info().
*/
function references_dialog_autoload_info() {
return array(
'references_dialog_plugin_display' => 'views/references_dialog_plugin_display.inc',
);
}

/**
* Implements hook_menu().
*/
function references_dialog_menu() {
$items = array();
// This redirect callback is used when adding and editing content in
// the overlay. When content is created or edited, we are directed here,
// so we can act properly on entities.
$items['references-dialog/redirect/%/%'] = array(
'page callback' => 'references_dialog_redirect_page',
'page arguments' => array(2, 3),
'access callback' => 'references_dialog_redirect_access',
'access arguments' => array(2, 3),
);
return $items;
}

/**
* Implements hook_theme().
*/
function references_dialog_theme() {
return array(
'references_dialog_links' => array(
'variables' => array('links' => NULL),
),
);
}

/**
* Implements hook_element_info().
*/
Expand Down Expand Up @@ -42,32 +79,6 @@ function references_dialog_element_info_alter(&$info) {
}
}

/**
* Implements hook_autoload_info().
*/
function references_dialog_autoload_info() {
return array(
'references_dialog_plugin_display' => 'views/references_dialog_plugin_display.inc',
);
}

/**
* Implements hook_menu().
*/
function references_dialog_menu() {
$items = array();
// This redirect callback is used when adding and editing content in
// the overlay. When content is created or edited, we are directed here,
// so we can act properly on entities.
$items['references-dialog/redirect/%/%'] = array(
'page callback' => 'references_dialog_redirect_page',
'page arguments' => array(2, 3),
'access callback' => 'references_dialog_redirect_access',
'access arguments' => array(2, 3),
);
return $items;
}

/**
* Implements hook_admin_paths().
*/
Expand Down Expand Up @@ -393,17 +404,6 @@ function references_dialog_js_settings($id, array $settings) {
);
}

/**
* Implements hook_theme().
*/
function references_dialog_theme() {
return array(
'references_dialog_links' => array(
'variables' => array('links' => NULL),
),
);
}

/**
* Implements hook_entity_insert().
*/
Expand Down Expand Up @@ -543,6 +543,18 @@ function references_dialog_get_views_search_links($attachable) {
return $links;
}

/**
* Implements hook_preprocess_page().
*/
function references_dialog_preprocess_page(&$variables) {

if (references_dialog_in_dialog()) {
$variables['page'] = '<div id="references-dialog-page">' . $variables['page'] . '</div>';
backdrop_add_js('file', '/js/search-reference.js',);
}
}


/**
* Check if we are in a references dialog.
* @return boolean if we are in a dialog.
Expand Down
2 changes: 0 additions & 2 deletions views/references_dialog_plugin_display.inc
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ class references_dialog_plugin_display extends views_plugin_display {
return $items;
}

function uses_exposed() { return TRUE; }

/**
* Override references_plugin_display, and
* allow for other style types.
Expand Down

0 comments on commit 611d4cf

Please sign in to comment.