Chris@0: /**
Chris@0: * DO NOT EDIT THIS FILE.
Chris@0: * See the following change record for more information,
Chris@0: * https://www.drupal.org/node/2815083
Chris@0: * @preserve
Chris@0: **/
Chris@0:
Chris@0: (function ($, Drupal, drupalSettings) {
Chris@0: Drupal.viewsUi = {};
Chris@0:
Chris@0: Drupal.behaviors.viewsUiEditView = {
Chris@0: attach: function attach() {
Chris@0: $('[data-drupal-selector="edit-query-options-disable-sql-rewrite"]').on('click', function () {
Chris@0: $('.sql-rewrite-warning').toggleClass('js-hide');
Chris@0: });
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiAddView = {
Chris@0: attach: function attach(context) {
Chris@0: var $context = $(context);
Chris@0:
Chris@0: var exclude = new RegExp('[^a-z0-9\\-]+', 'g');
Chris@0: var replace = '-';
Chris@0: var suffix = void 0;
Chris@0:
Chris@0: var $fields = $context.find('[id^="edit-page-title"], [id^="edit-block-title"], [id^="edit-page-link-properties-title"]');
Chris@0: if ($fields.length) {
Chris@0: if (!this.fieldsFiller) {
Chris@0: this.fieldsFiller = new Drupal.viewsUi.FormFieldFiller($fields);
Chris@0: } else {
Chris@0: this.fieldsFiller.rebind($fields);
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: var $pathField = $context.find('[id^="edit-page-path"]');
Chris@0: if ($pathField.length) {
Chris@0: if (!this.pathFiller) {
Chris@0: this.pathFiller = new Drupal.viewsUi.FormFieldFiller($pathField, exclude, replace);
Chris@0: } else {
Chris@0: this.pathFiller.rebind($pathField);
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: var $feedField = $context.find('[id^="edit-page-feed-properties-path"]');
Chris@0: if ($feedField.length) {
Chris@0: if (!this.feedFiller) {
Chris@0: suffix = '.xml';
Chris@0: this.feedFiller = new Drupal.viewsUi.FormFieldFiller($feedField, exclude, replace, suffix);
Chris@0: } else {
Chris@0: this.feedFiller.rebind($feedField);
Chris@0: }
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.FormFieldFiller = function ($target, exclude, replace, suffix) {
Chris@0: this.source = $('#edit-label');
Chris@0:
Chris@0: this.target = $target;
Chris@0:
Chris@0: this.exclude = exclude || false;
Chris@0:
Chris@0: this.replace = replace || '';
Chris@0:
Chris@0: this.suffix = suffix || '';
Chris@0:
Chris@0: var self = this;
Chris@0:
Chris@0: this.populate = function () {
Chris@0: return self._populate.call(self);
Chris@0: };
Chris@0:
Chris@0: this.unbind = function () {
Chris@0: return self._unbind.call(self);
Chris@0: };
Chris@0:
Chris@0: this.bind();
Chris@0: };
Chris@0:
Chris@0: $.extend(Drupal.viewsUi.FormFieldFiller.prototype, {
Chris@0: bind: function bind() {
Chris@0: this.unbind();
Chris@0:
Chris@0: this.source.on('keyup.viewsUi change.viewsUi', this.populate);
Chris@0:
Chris@0: this.target.on('focus.viewsUi', this.unbind);
Chris@0: },
Chris@0: getTransliterated: function getTransliterated() {
Chris@0: var from = this.source.val();
Chris@0: if (this.exclude) {
Chris@0: from = from.toLowerCase().replace(this.exclude, this.replace);
Chris@0: }
Chris@0: return from;
Chris@0: },
Chris@0: _populate: function _populate() {
Chris@0: var transliterated = this.getTransliterated();
Chris@0: var suffix = this.suffix;
Chris@0: this.target.each(function (i) {
Chris@0: var maxlength = $(this).attr('maxlength') - suffix.length;
Chris@0: $(this).val(transliterated.substr(0, maxlength) + suffix);
Chris@0: });
Chris@0: },
Chris@0: _unbind: function _unbind() {
Chris@0: this.source.off('keyup.viewsUi change.viewsUi', this.populate);
Chris@0: this.target.off('focus.viewsUi', this.unbind);
Chris@0: },
Chris@0: rebind: function rebind($fields) {
Chris@0: this.target = $fields;
Chris@0: this.bind();
Chris@0: }
Chris@0: });
Chris@0:
Chris@0: Drupal.behaviors.addItemForm = {
Chris@0: attach: function attach(context) {
Chris@0: var $context = $(context);
Chris@0: var $form = $context;
Chris@0:
Chris@0: if (!$context.is('form[id^="views-ui-add-handler-form"]')) {
Chris@0: $form = $context.find('form[id^="views-ui-add-handler-form"]');
Chris@0: }
Chris@0: if ($form.once('views-ui-add-handler-form').length) {
Chris@0: new Drupal.viewsUi.AddItemForm($form);
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.AddItemForm = function ($form) {
Chris@0: this.$form = $form;
Chris@0: this.$form.find('.views-filterable-options :checkbox').on('click', $.proxy(this.handleCheck, this));
Chris@0:
Chris@0: this.$selected_div = this.$form.find('.views-selected-options').parent();
Chris@0: this.$selected_div.hide();
Chris@0:
Chris@0: this.checkedItems = [];
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.AddItemForm.prototype.handleCheck = function (event) {
Chris@0: var $target = $(event.target);
Chris@0: var label = $.trim($target.closest('td').next().html());
Chris@0:
Chris@0: if ($target.is(':checked')) {
Chris@0: this.$selected_div.show().css('display', 'block');
Chris@0: this.checkedItems.push(label);
Chris@0: } else {
Chris@0: var position = $.inArray(label, this.checkedItems);
Chris@0:
Chris@0: for (var i = 0; i < this.checkedItems.length; i++) {
Chris@0: if (i === position) {
Chris@0: this.checkedItems.splice(i, 1);
Chris@0: i--;
Chris@0: break;
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: if (this.checkedItems.length === 0) {
Chris@0: this.$selected_div.hide();
Chris@0: }
Chris@0: }
Chris@0: this.refreshCheckedItems();
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.AddItemForm.prototype.refreshCheckedItems = function () {
Chris@0: this.$selected_div.find('.views-selected-options').html(this.checkedItems.join(', ')).trigger('dialogContentResize');
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiRenderAddViewButton = {
Chris@0: attach: function attach(context) {
Chris@0: var $menu = $(context).find('#views-display-menu-tabs').once('views-ui-render-add-view-button');
Chris@0: if (!$menu.length) {
Chris@0: return;
Chris@0: }
Chris@0:
Chris@0: var $addDisplayDropdown = $('
' + Drupal.t('Add') + '');
Chris@0: var $displayButtons = $menu.nextAll('input.add-display').detach();
Chris@0: $displayButtons.appendTo($addDisplayDropdown.find('.action-list')).wrap('').parent().eq(0).addClass('first').end().eq(-1).addClass('last');
Chris@0:
Chris@0: $displayButtons.each(function () {
Chris@0: var label = $(this).val();
Chris@0: if (label.substr(0, 4) === 'Add ') {
Chris@0: $(this).val(label.substr(4));
Chris@0: }
Chris@0: });
Chris@0: $addDisplayDropdown.appendTo($menu);
Chris@0:
Chris@0: $menu.find('li.add > a').on('click', function (event) {
Chris@0: event.preventDefault();
Chris@0: var $trigger = $(this);
Chris@0: Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu($trigger);
Chris@0: });
Chris@0:
Chris@0: $('li.add', $menu).on('mouseleave', function (event) {
Chris@0: var $this = $(this);
Chris@0: var $trigger = $this.children('a[href="#"]');
Chris@0: if ($this.children('.action-list').is(':visible')) {
Chris@0: Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu($trigger);
Chris@0: }
Chris@0: });
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu = function ($trigger) {
Chris@0: $trigger.parent().toggleClass('open');
Chris@0: $trigger.next().slideToggle('fast');
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiSearchOptions = {
Chris@0: attach: function attach(context) {
Chris@0: var $context = $(context);
Chris@0: var $form = $context;
Chris@0:
Chris@0: if (!$context.is('form[id^="views-ui-add-handler-form"]')) {
Chris@0: $form = $context.find('form[id^="views-ui-add-handler-form"]');
Chris@0: }
Chris@0:
Chris@0: if ($form.once('views-ui-filter-options').length) {
Chris@0: new Drupal.viewsUi.OptionsSearch($form);
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.OptionsSearch = function ($form) {
Chris@0: this.$form = $form;
Chris@0:
Chris@0: this.$form.on('click', 'td.title', function (event) {
Chris@0: var $target = $(event.currentTarget);
Chris@0: $target.closest('tr').find('input').trigger('click');
Chris@0: });
Chris@0:
Chris@0: var searchBoxSelector = '[data-drupal-selector="edit-override-controls-options-search"]';
Chris@0: var controlGroupSelector = '[data-drupal-selector="edit-override-controls-group"]';
Chris@0: this.$form.on('formUpdated', searchBoxSelector + ',' + controlGroupSelector, $.proxy(this.handleFilter, this));
Chris@0:
Chris@0: this.$searchBox = this.$form.find(searchBoxSelector);
Chris@0: this.$controlGroup = this.$form.find(controlGroupSelector);
Chris@0:
Chris@0: this.options = this.getOptions(this.$form.find('.filterable-option'));
Chris@0:
Chris@0: this.$searchBox.on('keypress', function (event) {
Chris@0: if (event.which === 13) {
Chris@0: event.preventDefault();
Chris@0: }
Chris@0: });
Chris@0: };
Chris@0:
Chris@0: $.extend(Drupal.viewsUi.OptionsSearch.prototype, {
Chris@0: getOptions: function getOptions($allOptions) {
Chris@0: var $title = void 0;
Chris@0: var $description = void 0;
Chris@0: var $option = void 0;
Chris@0: var options = [];
Chris@0: var length = $allOptions.length;
Chris@0: for (var i = 0; i < length; i++) {
Chris@0: $option = $($allOptions[i]);
Chris@0: $title = $option.find('.title');
Chris@0: $description = $option.find('.description');
Chris@0: options[i] = {
Chris@0: searchText: $title.text().toLowerCase() + ' ' + $description.text().toLowerCase(),
Chris@0:
Chris@0: $div: $option
Chris@0: };
Chris@0: }
Chris@0: return options;
Chris@0: },
Chris@0: handleFilter: function handleFilter(event) {
Chris@0: var search = this.$searchBox.val().toLowerCase();
Chris@0: var words = search.split(' ');
Chris@0:
Chris@0: var group = this.$controlGroup.val();
Chris@0:
Chris@0: this.options.forEach(function (option) {
Chris@0: function hasWord(word) {
Chris@0: return option.searchText.indexOf(word) !== -1;
Chris@0: }
Chris@0:
Chris@0: var found = true;
Chris@0:
Chris@0: if (search) {
Chris@0: found = words.every(hasWord);
Chris@0: }
Chris@0: if (found && group !== 'all') {
Chris@0: found = option.$div.hasClass(group);
Chris@0: }
Chris@0:
Chris@0: option.$div.toggle(found);
Chris@0: });
Chris@0:
Chris@0: $(event.target).trigger('dialogContentResize');
Chris@0: }
Chris@0: });
Chris@0:
Chris@0: Drupal.behaviors.viewsUiPreview = {
Chris@0: attach: function attach(context) {
Chris@0: var $contextualFiltersBucket = $(context).find('.views-display-column .views-ui-display-tab-bucket.argument');
Chris@0: if ($contextualFiltersBucket.length === 0) {
Chris@0: return;
Chris@0: }
Chris@0:
Chris@0: var $contextualFilters = $contextualFiltersBucket.find('.views-display-setting a');
Chris@0: if ($contextualFilters.length) {
Chris@0: $('#preview-args').parent().show();
Chris@0: } else {
Chris@0: $('#preview-args').parent().hide();
Chris@0: }
Chris@0:
Chris@0: if ($('#edit-displays-live-preview').once('edit-displays-live-preview').is(':checked')) {
Chris@0: $('#preview-submit').once('edit-displays-live-preview').trigger('click');
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiRearrangeFilter = {
Chris@0: attach: function attach(context) {
Chris@0: if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') {
Chris@0: return;
Chris@0: }
Chris@0: var $context = $(context);
Chris@0: var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters');
Chris@0: var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters');
Chris@0: if ($table.length) {
Chris@0: new Drupal.viewsUi.RearrangeFilterHandler($table, $operator);
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.RearrangeFilterHandler = function ($table, $operator) {
Chris@0: this.table = $table;
Chris@0:
Chris@0: this.operator = $operator;
Chris@0:
Chris@0: this.hasGroupOperator = this.operator.length > 0;
Chris@0:
Chris@0: this.draggableRows = $table.find('.draggable');
Chris@0:
Chris@0: this.addGroupButton = $('input#views-add-group');
Chris@0:
Chris@0: this.removeGroupButtons = $table.find('input.views-remove-group');
Chris@0:
Chris@0: this.insertAddRemoveFilterGroupLinks();
Chris@0:
Chris@0: if (this.hasGroupOperator) {
Chris@0: this.dropdowns = this.duplicateGroupsOperator();
Chris@0: this.syncGroupsOperators();
Chris@0: }
Chris@0:
Chris@0: this.modifyTableDrag();
Chris@0:
Chris@0: this.redrawOperatorLabels();
Chris@0: $table.find('.views-group-title select').once('views-rearrange-filter-handler').on('change.views-rearrange-filter-handler', $.proxy(this, 'redrawOperatorLabels'));
Chris@0:
Chris@0: $table.find('a.views-groups-remove-link').once('views-rearrange-filter-handler').on('click.views-rearrange-filter-handler', $.proxy(this, 'updateRowspans')).on('click.views-rearrange-filter-handler', $.proxy(this, 'redrawOperatorLabels'));
Chris@0: };
Chris@0:
Chris@0: $.extend(Drupal.viewsUi.RearrangeFilterHandler.prototype, {
Chris@0: insertAddRemoveFilterGroupLinks: function insertAddRemoveFilterGroupLinks() {
Chris@0: $('').prependTo(this.table.parent()).once('views-rearrange-filter-handler').find('#views-add-group-link').on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton'));
Chris@0:
Chris@0: var length = this.removeGroupButtons.length;
Chris@0: var i = void 0;
Chris@0: for (i = 0; i < length; i++) {
Chris@0: var $removeGroupButton = $(this.removeGroupButtons[i]);
Chris@0: var buttonId = $removeGroupButton.attr('id');
Chris@0: $('' + Drupal.t('Remove group') + '').insertBefore($removeGroupButton).once('views-rearrange-filter-handler').on('click.views-rearrange-filter-handler', { buttonId: buttonId }, $.proxy(this, 'clickRemoveGroupButton'));
Chris@0: }
Chris@0: },
Chris@0: clickAddGroupButton: function clickAddGroupButton(event) {
Chris@0: this.addGroupButton.trigger('mousedown');
Chris@0: event.preventDefault();
Chris@0: },
Chris@0: clickRemoveGroupButton: function clickRemoveGroupButton(event) {
Chris@0: this.table.find('#' + event.data.buttonId).trigger('mousedown');
Chris@0: event.preventDefault();
Chris@0: },
Chris@0: duplicateGroupsOperator: function duplicateGroupsOperator() {
Chris@0: var newRow = void 0;
Chris@0: var titleRow = void 0;
Chris@0:
Chris@0: var titleRows = $('tr.views-group-title').once('duplicateGroupsOperator');
Chris@0:
Chris@0: if (!titleRows.length) {
Chris@0: return this.operator;
Chris@0: }
Chris@0:
Chris@0: this.operator.find('label').add('div.description').addClass('visually-hidden');
Chris@0: this.operator.find('select').addClass('form-select');
Chris@0:
Chris@14: var dropdowns = this.operator;
Chris@0:
Chris@0: titleRow = $('tr#views-group-title-2');
Chris@0: newRow = $(' |
');
Chris@0: newRow.find('td').append(this.operator);
Chris@0: newRow.insertBefore(titleRow);
Chris@0: var length = titleRows.length;
Chris@0:
Chris@0: for (var i = 2; i < length; i++) {
Chris@0: titleRow = $(titleRows[i]);
Chris@0:
Chris@0: var fakeOperator = this.operator.clone();
Chris@0: fakeOperator.attr('id', '');
Chris@0: newRow = $(' |
');
Chris@0: newRow.find('td').append(fakeOperator);
Chris@0: newRow.insertBefore(titleRow);
Chris@0: dropdowns.add(fakeOperator);
Chris@0: }
Chris@0:
Chris@0: return dropdowns;
Chris@0: },
Chris@0: syncGroupsOperators: function syncGroupsOperators() {
Chris@0: if (this.dropdowns.length < 2) {
Chris@0: return;
Chris@0: }
Chris@0:
Chris@0: this.dropdowns.on('change', $.proxy(this, 'operatorChangeHandler'));
Chris@0: },
Chris@0: operatorChangeHandler: function operatorChangeHandler(event) {
Chris@0: var $target = $(event.target);
Chris@0: var operators = this.dropdowns.find('select').not($target);
Chris@0:
Chris@0: operators.val($target.val());
Chris@0: },
Chris@0: modifyTableDrag: function modifyTableDrag() {
Chris@0: var tableDrag = Drupal.tableDrag['views-rearrange-filters'];
Chris@0: var filterHandler = this;
Chris@0:
Chris@0: tableDrag.row.prototype.onSwap = function () {
Chris@0: if (filterHandler.hasGroupOperator) {
Chris@0: var thisRow = $(this.group);
Chris@0: var previousRow = thisRow.prev('tr');
Chris@0: if (previousRow.length && !previousRow.hasClass('group-message') && !previousRow.hasClass('draggable')) {
Chris@0: var next = thisRow.next();
Chris@0: if (next.is('tr')) {
Chris@0: this.swap('after', next);
Chris@0: }
Chris@0: }
Chris@0: filterHandler.updateRowspans();
Chris@0: }
Chris@0:
Chris@0: filterHandler.redrawOperatorLabels();
Chris@0: };
Chris@0:
Chris@0: tableDrag.onDrop = function () {
Chris@0: var changeMarker = $(this.oldRowElement).find('.tabledrag-changed');
Chris@0: if (changeMarker.length) {
Chris@0: var operatorLabel = changeMarker.prevAll('.views-operator-label');
Chris@0: if (operatorLabel.length) {
Chris@0: operatorLabel.insertAfter(changeMarker);
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: var groupRow = $(this.rowObject.element).prevAll('tr.group-message').get(0);
Chris@0: var groupName = groupRow.className.replace(/([^ ]+[ ]+)*group-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
Chris@0: var groupField = $('select.views-group-select', this.rowObject.element);
Chris@18: if (!groupField.is('.views-group-select-' + groupName)) {
Chris@0: var oldGroupName = groupField.attr('class').replace(/([^ ]+[ ]+)*views-group-select-([^ ]+)([ ]+[^ ]+)*/, '$2');
Chris@0: groupField.removeClass('views-group-select-' + oldGroupName).addClass('views-group-select-' + groupName);
Chris@0: groupField.val(groupName);
Chris@0: }
Chris@0: };
Chris@0: },
Chris@0: redrawOperatorLabels: function redrawOperatorLabels() {
Chris@0: for (var i = 0; i < this.draggableRows.length; i++) {
Chris@0: var $draggableRow = $(this.draggableRows[i]);
Chris@0: var $firstCell = $draggableRow.find('td').eq(0);
Chris@0: if ($firstCell.length) {
Chris@0: var operatorValue = $draggableRow.prevAll('.views-group-title').find('option:selected').html();
Chris@0: var operatorLabel = '' + operatorValue + '';
Chris@0:
Chris@0: var $nextRow = $draggableRow.nextAll(':visible').eq(0);
Chris@0: var $existingOperatorLabel = $firstCell.find('.views-operator-label');
Chris@0: if ($nextRow.hasClass('draggable')) {
Chris@0: if ($existingOperatorLabel.length) {
Chris@0: $existingOperatorLabel.replaceWith(operatorLabel);
Chris@0: } else {
Chris@0: $firstCell.append(operatorLabel);
Chris@0: }
Chris@0: } else {
Chris@0: $existingOperatorLabel.remove();
Chris@0: }
Chris@0: }
Chris@0: }
Chris@0: },
Chris@0: updateRowspans: function updateRowspans() {
Chris@0: var $row = void 0;
Chris@0: var $currentEmptyRow = void 0;
Chris@0: var draggableCount = void 0;
Chris@0: var $operatorCell = void 0;
Chris@0: var rows = $(this.table).find('tr');
Chris@0: var length = rows.length;
Chris@0: for (var i = 0; i < length; i++) {
Chris@0: $row = $(rows[i]);
Chris@0: if ($row.hasClass('views-group-title')) {
Chris@0: $operatorCell = $row.find('td.group-operator');
Chris@0:
Chris@0: draggableCount = 0;
Chris@0: $currentEmptyRow = $row.next('tr');
Chris@0: $currentEmptyRow.removeClass('group-populated').addClass('group-empty');
Chris@0:
Chris@0: $operatorCell.attr('rowspan', 2);
Chris@0: } else if ($row.hasClass('draggable') && $row.is(':visible')) {
Chris@0: draggableCount++;
Chris@0: $currentEmptyRow.removeClass('group-empty').addClass('group-populated');
Chris@0:
Chris@0: $operatorCell.attr('rowspan', draggableCount + 1);
Chris@0: }
Chris@0: }
Chris@0: }
Chris@0: });
Chris@0:
Chris@0: Drupal.behaviors.viewsFilterConfigSelectAll = {
Chris@0: attach: function attach(context) {
Chris@0: var $context = $(context);
Chris@0:
Chris@0: var $selectAll = $context.find('.js-form-item-options-value-all').once('filterConfigSelectAll');
Chris@0: var $selectAllCheckbox = $selectAll.find('input[type=checkbox]');
Chris@0: var $checkboxes = $selectAll.closest('.form-checkboxes').find('.js-form-type-checkbox:not(.js-form-item-options-value-all) input[type="checkbox"]');
Chris@0:
Chris@0: if ($selectAll.length) {
Chris@0: $selectAll.show();
Chris@0: $selectAllCheckbox.on('click', function () {
Chris@0: $checkboxes.prop('checked', $(this).is(':checked'));
Chris@0: });
Chris@0:
Chris@0: $checkboxes.on('click', function () {
Chris@0: if ($(this).is('checked') === false) {
Chris@0: $selectAllCheckbox.prop('checked', false);
Chris@0: }
Chris@0: });
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsRemoveIconClass = {
Chris@0: attach: function attach(context) {
Chris@0: $(context).find('.dropbutton').once('dropbutton-icon').find('.icon').removeClass('icon');
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiCheckboxify = {
Chris@0: attach: function attach(context, settings) {
Chris@0: var $buttons = $('[data-drupal-selector="edit-options-expose-button-button"], [data-drupal-selector="edit-options-group-button-button"]').once('views-ui-checkboxify');
Chris@0: var length = $buttons.length;
Chris@0: var i = void 0;
Chris@0: for (i = 0; i < length; i++) {
Chris@0: new Drupal.viewsUi.Checkboxifier($buttons[i]);
Chris@0: }
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiChangeDefaultWidget = {
Chris@0: attach: function attach(context) {
Chris@0: var $context = $(context);
Chris@0:
Chris@0: function changeDefaultWidget(event) {
Chris@0: if ($(event.target).prop('checked')) {
Chris@0: $context.find('input.default-radios').parent().hide();
Chris@0: $context.find('td.any-default-radios-row').parent().hide();
Chris@0: $context.find('input.default-checkboxes').parent().show();
Chris@0: } else {
Chris@0: $context.find('input.default-checkboxes').parent().hide();
Chris@0: $context.find('td.any-default-radios-row').parent().show();
Chris@0: $context.find('input.default-radios').parent().show();
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: $context.find('input[name="options[group_info][multiple]"]').on('change', changeDefaultWidget).trigger('change');
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.Checkboxifier = function (button) {
Chris@0: this.$button = $(button);
Chris@0: this.$parent = this.$button.parent('div.views-expose, div.views-grouped');
Chris@0: this.$input = this.$parent.find('input:checkbox, input:radio');
Chris@0:
Chris@0: this.$button.hide();
Chris@0: this.$parent.find('.exposed-description, .grouped-description').hide();
Chris@0:
Chris@0: this.$input.on('click', $.proxy(this, 'clickHandler'));
Chris@0: };
Chris@0:
Chris@0: Drupal.viewsUi.Checkboxifier.prototype.clickHandler = function (e) {
Chris@0: this.$button.trigger('click').trigger('submit');
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiOverrideSelect = {
Chris@0: attach: function attach(context) {
Chris@0: $(context).find('[data-drupal-selector="edit-override-dropdown"]').once('views-ui-override-button-text').each(function () {
Chris@0: var $context = $(context);
Chris@0: var $submit = $context.find('[id^=edit-submit]');
Chris@14: var oldValue = $submit.val();
Chris@0:
Chris@0: $submit.once('views-ui-override-button-text').on('mouseup', function () {
Chris@14: $(this).val(oldValue);
Chris@0: return true;
Chris@0: });
Chris@0:
Chris@0: $(this).on('change', function () {
Chris@0: var $this = $(this);
Chris@0: if ($this.val() === 'default') {
Chris@0: $submit.val(Drupal.t('Apply (all displays)'));
Chris@0: } else if ($this.val() === 'default_revert') {
Chris@0: $submit.val(Drupal.t('Revert to default'));
Chris@0: } else {
Chris@0: $submit.val(Drupal.t('Apply (this display)'));
Chris@0: }
Chris@0: var $dialog = $context.closest('.ui-dialog-content');
Chris@0: $dialog.trigger('dialogButtonsChange');
Chris@0: }).trigger('change');
Chris@0: });
Chris@0: }
Chris@0: };
Chris@0:
Chris@0: Drupal.behaviors.viewsUiHandlerRemoveLink = {
Chris@0: attach: function attach(context) {
Chris@0: var $context = $(context);
Chris@0:
Chris@0: $context.find('a.views-remove-link').once('views').on('click', function (event) {
Chris@0: var id = $(this).attr('id').replace('views-remove-link-', '');
Chris@0: $context.find('#views-row-' + id).hide();
Chris@0: $context.find('#views-removed-' + id).prop('checked', true);
Chris@0: event.preventDefault();
Chris@0: });
Chris@0:
Chris@0: $context.find('a.display-remove-link').once('display').on('click', function (event) {
Chris@0: var id = $(this).attr('id').replace('display-remove-link-', '');
Chris@0: $context.find('#display-row-' + id).hide();
Chris@0: $context.find('#display-removed-' + id).prop('checked', true);
Chris@0: event.preventDefault();
Chris@0: });
Chris@0: }
Chris@0: };
Chris@0: })(jQuery, Drupal, drupalSettings);