From 182ca63a38205cdf53d99d1398c04279c50d9fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Kr=C3=A4ftner?= Date: Fri, 20 Oct 2017 11:43:45 +0200 Subject: [PATCH] determine select2 version from ACF --- js/src/scraper/scraper.taxonomy.js | 2 +- js/yoast-acf-analysis.js | 2 +- tests/js/system/tests/acf5/relational.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/src/scraper/scraper.taxonomy.js b/js/src/scraper/scraper.taxonomy.js index 75133f8e..66551d9d 100644 --- a/js/src/scraper/scraper.taxonomy.js +++ b/js/src/scraper/scraper.taxonomy.js @@ -17,7 +17,7 @@ Scraper.prototype.scrape = function(fields){ if( field.$el.find('.acf-taxonomy-field[data-type="multi_select"]').length > 0 ){ - var select2Target = (helper.acf_version >= 5.6)?'select':'input'; + var select2Target = (acf.select2.version >= 4)?'select':'input'; terms = _.pluck( field.$el.find('.acf-taxonomy-field[data-type="multi_select"] ' + select2Target ) diff --git a/js/yoast-acf-analysis.js b/js/yoast-acf-analysis.js index 3df6c386..612bc67a 100644 --- a/js/yoast-acf-analysis.js +++ b/js/yoast-acf-analysis.js @@ -688,7 +688,7 @@ Scraper.prototype.scrape = function(fields){ if( field.$el.find('.acf-taxonomy-field[data-type="multi_select"]').length > 0 ){ - var select2Target = (helper.acf_version >= 5.6)?'select':'input'; + var select2Target = (acf.select2.version >= 4)?'select':'input'; terms = _.pluck( field.$el.find('.acf-taxonomy-field[data-type="multi_select"] ' + select2Target ) diff --git a/tests/js/system/tests/acf5/relational.js b/tests/js/system/tests/acf5/relational.js index adcb33e5..aee2c659 100644 --- a/tests/js/system/tests/acf5/relational.js +++ b/tests/js/system/tests/acf5/relational.js @@ -34,14 +34,14 @@ module.exports = { browser.execute( function() { - return parseFloat(YoastACFAnalysisConfig.acfVersion, 10); + return parseFloat(acf.select2.version, 10); }, [], function( result ){ - var acfVersion = result.value; + var select2Version = result.value; var inputSelector, optionSelector, choiceSelector; - if( acfVersion >= 5.6 ){ + if( select2Version >= 4 ){ inputSelector = '.acf-taxonomy-field[data-type="multi_select"][data-taxonomy="category"] .select2-search__field '; optionSelector = '.select2-results__option--highlighted'; choiceSelector = '.acf-taxonomy-field .select2-selection__choice'; @@ -64,7 +64,7 @@ module.exports = { browser.execute( function() { - var select2Target = (parseFloat(YoastACFAnalysisConfig.acfVersion, 10) >= 5.6)?'select':'input'; + var select2Target = (parseFloat(acf.select2.version, 10) >= 4)?'select':'input'; return jQuery('.acf-taxonomy-field[data-type="multi_select"] ' + select2Target).select2('data')[0].text },