diff --git a/composer.json b/composer.json index 87ca610..f52ed8a 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "source": "https://git.drupalcode.org/project/fivestar" }, "require": { - "drupal/core": "^9.2", + "drupal/core": "^9.2 || ^10", "drupal/votingapi": "^3.0" }, "minimum-stability": "dev" diff --git a/fivestar.info.yml b/fivestar.info.yml index 98a8b54..da7bb11 100644 --- a/fivestar.info.yml +++ b/fivestar.info.yml @@ -2,7 +2,7 @@ name: Fivestar type: module description: 'Enables fivestar ratings on content, users, etc.' package: Voting -core_version_requirement: ^9.2 +core_version_requirement: ^9.2 || ^10 dependencies: - votingapi:votingapi diff --git a/fivestar.libraries.yml b/fivestar.libraries.yml index 1e829b7..90123d1 100644 --- a/fivestar.libraries.yml +++ b/fivestar.libraries.yml @@ -7,9 +7,9 @@ fivestar.base: js/fivestar.js: {} dependencies: - - core/jquery - core/drupal - - core/jquery.once + - core/jquery + - core/once - core/drupal.ajax fivestar.admin: @@ -18,15 +18,6 @@ fivestar.admin: component: css/fivestar-admin.css: {} -fivestar.ajax: - version: VERSION - js: - js/fivestar.ajax.js: {} - dependencies: - - core/jquery - - core/drupal - - core/jquery.once - # Widgets # Right now does not include RTL handling basic: diff --git a/fivestar.module b/fivestar.module index dbc4e2c..4ad1917 100644 --- a/fivestar.module +++ b/fivestar.module @@ -78,17 +78,6 @@ function fivestar_theme() { 'microdata' => [], ], ], - 'fivestar_preview' => [ - 'function' => 'theme_fivestar_preview', - 'variables' => [ - 'style' => NULL, - 'text' => NULL, - 'stars' => NULL, - 'unvote' => NULL, - 'title' => NULL, - ], - 'file' => 'includes/fivestar.theme.inc', - ], 'fivestar_formatter_rating' => [ 'render element' => 'element', ], diff --git a/includes/fivestar.theme.inc b/includes/fivestar.theme.inc deleted file mode 100644 index e1cbda6..0000000 --- a/includes/fivestar.theme.inc +++ /dev/null @@ -1,44 +0,0 @@ - 50, - 'vote_user' => 80, - 'vote_count' => 20, - ]; - $settings = [ - 'stars' => $stars, - 'allow_clear' => $unvote, - 'allow_revote' => $revote, - 'allow_ownvote' => $ownvote, - 'style' => $style, - 'text' => $text, - 'title' => $title, - 'autosubmit' => FALSE, - 'vote_type' => 'vote', - ]; - - $form = drupal_get_form('fivestar_custom_widget', $values, $settings); - $form = \Drupal::service('renderer')->render($form); - // This regex is sadly necessary because having duplicate form_tokens or - // form_id elements can cause the content type form to choke. Forms inside of - // forms is also frowned upon, so this removes the wrapping form tag as well. - $form = str_replace([''], [ - '', - ], $form); - $form = preg_replace('/( method=".*?")|( action=".*?")|()/', '', $form); - return $form; -} diff --git a/js/fivestar.js b/js/fivestar.js index c1b7ac1..973e229 100644 --- a/js/fivestar.js +++ b/js/fivestar.js @@ -20,7 +20,7 @@ } }); - $(context).find('div.fivestar-form-item').once('fivestar').each(function() { + $(once('fivestar', 'div.fivestar-form-item', context)).each(function() { var $cancel, $container, $options, $select, $this, index; $this = $(this); $container = $('
'); @@ -89,21 +89,4 @@ } } }; -})(jQuery); - - -/** - * @file - * - * Fivestar AJAX for updating fivestar widgets. - */ - -/** - * Create a degradeable star rating interface out of a simple form structure. - */ -(function($) { - Drupal.AjaxCommands.prototype.fivestarUpdate = function(ajax, response, status) { - response.selector = $('.fivestar-form-item', ajax.element.form); - ajax.commands.insert(ajax, response, status); - }; -})(jQuery); +})(jQuery, once);