diff --git a/dist/onoffice-custom-select.min.js b/dist/onoffice-custom-select.min.js index cf3ff3a9f..6dfb37680 100644 --- a/dist/onoffice-custom-select.min.js +++ b/dist/onoffice-custom-select.min.js @@ -1 +1 @@ -onOffice=onOffice||{};onOffice.custom_select2_translation=onOffice.custom_select2_translation||[];jQuery(document).ready((function($){const $multiSelectAdminSorting=$("#viewrecordssorting .oo-custom-select2.oo-custom-select2--multiple");const $singleSelectAdminSorting=$("#viewrecordssorting .oo-custom-select2.oo-custom-select2--single");$(".custom-multiple-select, .custom-single-select").select2({width:"100%"});$multiSelectAdminSorting.select2({placeholder:custom_select2_translation.multipleSelectOptions,width:"50%"});$singleSelectAdminSorting.select2({placeholder:custom_select2_translation.singleSelectOption,width:"50%"})})); \ No newline at end of file +const custom_select2=typeof custom_select2_translation!=="undefined"?custom_select2_translation:{};jQuery(document).ready((function($){const $multiSelectAdminSorting=$("#viewrecordssorting .oo-custom-select2.oo-custom-select2--multiple");const $singleSelectAdminSorting=$("#viewrecordssorting .oo-custom-select2.oo-custom-select2--single");$(".custom-multiple-select, .custom-single-select").select2({width:"100%"});if($multiSelectAdminSorting.length){$multiSelectAdminSorting.select2({placeholder:custom_select2.multipleSelectOptions,width:"50%"})}if($singleSelectAdminSorting.length){$singleSelectAdminSorting.select2({placeholder:custom_select2.singleSelectOption,width:"50%"})}})); \ No newline at end of file diff --git a/js/onoffice-custom-select.js b/js/onoffice-custom-select.js index 75ea971d5..29bcd49d3 100644 --- a/js/onoffice-custom-select.js +++ b/js/onoffice-custom-select.js @@ -1,5 +1,4 @@ -onOffice = onOffice || {}; -onOffice.custom_select2_translation = onOffice.custom_select2_translation || []; +const custom_select2 = (typeof custom_select2_translation !== 'undefined') ? custom_select2_translation : {}; jQuery(document).ready(function ($) { const $multiSelectAdminSorting = $('#viewrecordssorting .oo-custom-select2.oo-custom-select2--multiple'); const $singleSelectAdminSorting = $("#viewrecordssorting .oo-custom-select2.oo-custom-select2--single"); @@ -8,13 +7,17 @@ jQuery(document).ready(function ($) { width: '100%' }); - $multiSelectAdminSorting.select2({ - placeholder: custom_select2_translation.multipleSelectOptions, - width: '50%' - }); + if ($multiSelectAdminSorting.length) { + $multiSelectAdminSorting.select2({ + placeholder: custom_select2.multipleSelectOptions, + width: '50%' + }); + } - $singleSelectAdminSorting.select2({ - placeholder: custom_select2_translation.singleSelectOption, - width: '50%' - }); + if ($singleSelectAdminSorting.length) { + $singleSelectAdminSorting.select2({ + placeholder: custom_select2.singleSelectOption, + width: '50%' + }); + } }); \ No newline at end of file