{"version":3,"file":"exposed-forms.min.js","sources":["exposed-forms.js"],"sourcesContent":["/**\n * @file\n * Contains the Exposed Filter Javascript.\n */\n\n(function ($, Drupal) {\n\n 'use strict'\n\n /**\n * Exposed Programming Form Drupal Behaviors.\n *\n * @type {{noOptionSelected: (function(*): boolean), initialState:\n * Drupal.behaviors.exposedProgrammingForm.initialState, submitForm:\n * Drupal.behaviors.exposedProgrammingForm.submitForm,\n * checkAllProgramingCheckbox:\n * Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox,\n * resetResults: Drupal.behaviors.exposedProgrammingForm.resetResults,\n * attach: Drupal.behaviors.exposedProgrammingForm.attach, checkOptions:\n * Drupal.behaviors.exposedProgrammingForm.checkOptions}}\n */\n Drupal.behaviors.exposedProgrammingForm = {\n attach: function (context, settings) {\n /*\n Each time that dom is affected we need to refresh the Toolkit.\n */\n componentHandler.upgradeElements($('#block-pressroom-content').get());\n // Define vars.\n var $exposed_form = $('#views-exposed-form-property-property-grid-programming', context);\n var $all_programing_checkbox = $('input[data-drupal-selector=\"edit-filter-by-options-all\"]', $($exposed_form));\n // Initial exposed form state.\n Drupal.behaviors.exposedProgrammingForm.initialState($exposed_form);\n /*\n All Programing Change event listener\n */\n $all_programing_checkbox.change(function (event) {\n // Don't actually follow the link.\n event.preventDefault();\n event.stopPropagation();\n if (!$(this).is(\":checked\")) {\n Drupal.behaviors.exposedProgrammingForm.checkOptions($exposed_form, false);\n }\n Drupal.behaviors.exposedProgrammingForm.submitForm($exposed_form);\n });\n /*\n Options event listener\n */\n $exposed_form.find('input[type=checkbox]')\n .filter(':not(input[data-drupal-selector=\"edit-filter-by-options-all\"])')\n .change(function (event) {\n if (!Drupal.behaviors.exposedProgrammingForm.noOptionSelected($exposed_form)) {\n // Check the All programing checkbox if option is selected.\n Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox($all_programing_checkbox, false);\n }\n if (Drupal.behaviors.exposedProgrammingForm.noOptionSelected($exposed_form)) {\n Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox($all_programing_checkbox, true);\n $all_programing_checkbox.change();\n }\n else {\n // Trigger the form.\n Drupal.behaviors.exposedProgrammingForm.submitForm($exposed_form);\n }\n });\n\n },\n /**\n * Initial Programming exposed form alters.\n *\n * @param $exposed_form\n */\n initialState: function ($exposed_form) {\n // Set 'inverted' class to the All programing checkbox.\n var $all_programing_checkbox = $('input[data-drupal-selector=\"edit-filter-by-options-all\"]', $($exposed_form));\n $all_programing_checkbox.addClass('inverted').siblings().addClass('inverted');\n /*\n Fixes the dom issue after infinity scroll ajax is completed.\n Issue description: the checkbox \"checked\" property is not consistent\n with the rendered html input. to fix it; Do the prop() again.\n */\n if ($all_programing_checkbox.is(\":checked\")) {\n $all_programing_checkbox.prop(\"checked\", true).siblings('label').addClass('checked');\n // Make toolkit visible.\n $exposed_form.find('.mdl-menu__container.is-upgraded').addClass('is-visible');\n }\n else {\n $all_programing_checkbox.prop(\"checked\", false).siblings('label').removeClass('checked');\n }\n /*\n If All options are unselected mark \"all\" option as checked ,\n also mark all options and the \"All Programing\" checkbox as checked.\n */\n if (Drupal.behaviors.exposedProgrammingForm.noOptionSelected($exposed_form)) {\n Drupal.behaviors.exposedProgrammingForm.checkOptions($exposed_form, true);\n Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox($all_programing_checkbox, true);\n }\n else {\n // If some option is selected, uncheck the all programing checkbox.\n Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox($all_programing_checkbox, false);\n }\n },\n /**\n * Returns TRUE if there is not some programming selected.\n *\n * @param $exposed_form\n */\n noOptionSelected: function ($exposed_form) {\n var options = true;\n $exposed_form.find('input[type=checkbox]')\n .filter(':not(input[data-drupal-selector=\"edit-filter-by-options-all\"])').each(function () {\n if ($(this).is(\":checked\")) {\n options = false;\n }\n });\n return options;\n },\n hideUnSelectedOptions: function ($exposed_form) {\n $exposed_form.find('input[type=checkbox]')\n .filter(':not(input[data-drupal-selector=\"edit-filter-by-options-all\"])').each(function () {\n if (!$(this).is(\":checked\")) {\n $(this).addClass('hidden').siblings('label').addClass('hidden');\n }\n });\n },\n /**\n * Check or Uncheck all programming.\n *\n * Check or Uncheck all programming (all options). given the checkboxes\n * statuses.\n *\n * @param $exposed_form\n */\n checkOptions: function ($exposed_form, checked_status) {\n $exposed_form\n .find('input[type=checkbox]')\n .filter(':not(input[data-drupal-selector=\"edit-filter-by-options-all\"])')\n .each(function () {\n $(this).prop(\"checked\", checked_status);\n });\n },\n /**\n * Check or uncheck the \"All Programing\" checkbox.\n *\n * @param $exposed_form\n */\n checkAllProgramingCheckbox: function ($all_option_checkbox, checked_status) {\n $all_option_checkbox.prop(\"checked\", !checked_status);\n },\n /**\n * Trigger the exposed programming filter form.\n *\n * @param $exposed_form\n */\n submitForm: function ($exposed_form) {\n var $action = $('.form-actions input[id^=\"edit-submit-property\"]', $($exposed_form));\n $action.click();\n }\n }\n\n /**\n * Exposed Programming Featured Form Drupal Behaviors.\n */\n Drupal.behaviors.exposedProgrammingFeaturedForm = {\n attach: function (context, settings) {\n\n // We can't use the context for searching within this element\n // because there are ajax operations for filtering using different contexts.\n var $exposed_form = $('#views-exposed-form-property-property-grid-programming-featured');\n if ($exposed_form.length > 0 ) {\n // Hide A-Z exposed filter and title.\n var $exposed_form_a_z = $('#views-exposed-form-property-property-grid-programming');\n var $all_programing_checkbox_a_z = $('input[data-drupal-selector=\"edit-filter-by-options-all\"]', $exposed_form_a_z);\n\n // Clean HTML when there are featured items.\n $('.exposed-programing-form', $exposed_form_a_z).hide();\n\n // All programming checkbox form field.\n var $all_programing_checkbox = $('input[data-drupal-selector=\"edit-filter-by-options-all\"]', $exposed_form);\n\n // Initial exposed form state.\n Drupal.behaviors.exposedProgrammingForm.initialState($exposed_form);\n /*\n All Programing Change event listener\n */\n $all_programing_checkbox.change(function (event) {\n // Don't actually follow the link.\n event.preventDefault();\n event.stopPropagation();\n if (!$(this).is(\":checked\")) {\n Drupal.behaviors.exposedProgrammingForm.checkOptions($exposed_form, false);\n }\n Drupal.behaviors.exposedProgrammingForm.submitForm($exposed_form);\n // Issue change in the filter to the A-Z view.\n $all_programing_checkbox_a_z.prop(\"checked\", $(this).is(\":checked\")).change();\n });\n /*\n Options event listener\n */\n $exposed_form.find('input[type=checkbox]')\n .filter(':not(input[data-drupal-selector=\"edit-filter-by-options-all\"])')\n .change(function (event) {\n if (!Drupal.behaviors.exposedProgrammingForm.noOptionSelected($exposed_form)) {\n // Check the All programing checkbox if option is selected.\n Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox($all_programing_checkbox, false);\n }\n if (Drupal.behaviors.exposedProgrammingForm.noOptionSelected($exposed_form)) {\n Drupal.behaviors.exposedProgrammingForm.checkAllProgramingCheckbox($all_programing_checkbox, true);\n $all_programing_checkbox.change();\n }\n else {\n // Trigger the form.\n Drupal.behaviors.exposedProgrammingForm.submitForm($exposed_form);\n }\n\n // Issue change in the filter to the A-Z view.\n var checkboxSelector = $(this).data('drupalSelector');\n var $exposed_form_a_z_item_changed = $exposed_form_a_z.find('input[data-drupal-selector=\"' + checkboxSelector + '\"]');\n\n if ($exposed_form_a_z_item_changed.length > 0) {\n $exposed_form_a_z_item_changed.prop(\"checked\", $(this).is(\":checked\")).change();\n }\n });\n }\n }\n }\n\n})(jQuery, Drupal);\n"],"names":["$","Drupal","behaviors","exposedProgrammingForm","attach","context","settings","componentHandler","upgradeElements","get","$exposed_form","$all_programing_checkbox","initialState","change","event","preventDefault","stopPropagation","this","is","checkOptions","submitForm","find","filter","noOptionSelected","checkAllProgramingCheckbox","addClass","siblings","prop","removeClass","options","each","hideUnSelectedOptions","checked_status","$all_option_checkbox","click","exposedProgrammingFeaturedForm","$exposed_form_a_z","$all_programing_checkbox_a_z","length","hide","checkboxSelector","data","$exposed_form_a_z_item_changed","jQuery"],"mappings":"CAKA,CAAWA,EAAGC,KAgBZA,EAAOC,UAAUC,uBAAyB,CACxCC,OAAQ,SAAUC,EAASC,GAIzBC,iBAAiB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