2009-05-17 11:16:51 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2013-10-16 19:18:57 +00:00
|
|
|
(function ($, Drupal, drupalSettings) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi = {};
|
|
|
|
Drupal.behaviors.viewsUiEditView = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach() {
|
2015-06-22 13:16:58 +00:00
|
|
|
$('[data-drupal-selector="edit-query-options-disable-sql-rewrite"]').on('click', function () {
|
2014-01-27 21:41:32 +00:00
|
|
|
$('.sql-rewrite-warning').toggleClass('js-hide');
|
|
|
|
});
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
Drupal.behaviors.viewsUiAddView = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
var exclude = new RegExp('[^a-z0-9\\-]+', 'g');
|
|
|
|
var replace = '-';
|
2020-01-30 09:08:38 +00:00
|
|
|
var suffix;
|
2020-01-28 13:12:54 +00:00
|
|
|
var $fields = $context.find('[id^="edit-page-title"], [id^="edit-block-title"], [id^="edit-page-link-properties-title"]');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($fields.length) {
|
|
|
|
if (!this.fieldsFiller) {
|
|
|
|
this.fieldsFiller = new Drupal.viewsUi.FormFieldFiller($fields);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.fieldsFiller.rebind($fields);
|
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var $pathField = $context.find('[id^="edit-page-path"]');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($pathField.length) {
|
|
|
|
if (!this.pathFiller) {
|
|
|
|
this.pathFiller = new Drupal.viewsUi.FormFieldFiller($pathField, exclude, replace);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.pathFiller.rebind($pathField);
|
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
var $feedField = $context.find('[id^="edit-page-feed-properties-path"]');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($feedField.length) {
|
|
|
|
if (!this.feedFiller) {
|
|
|
|
suffix = '.xml';
|
|
|
|
this.feedFiller = new Drupal.viewsUi.FormFieldFiller($feedField, exclude, replace, suffix);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.feedFiller.rebind($feedField);
|
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi.FormFieldFiller = function ($target, exclude, replace, suffix) {
|
|
|
|
this.source = $('#edit-label');
|
|
|
|
this.target = $target;
|
|
|
|
this.exclude = exclude || false;
|
|
|
|
this.replace = replace || '';
|
|
|
|
this.suffix = suffix || '';
|
|
|
|
var self = this;
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
this.populate = function () {
|
|
|
|
return self._populate.call(self);
|
|
|
|
};
|
|
|
|
|
|
|
|
this.unbind = function () {
|
|
|
|
return self._unbind.call(self);
|
|
|
|
};
|
2012-08-28 22:55:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
this.bind();
|
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
$.extend(Drupal.viewsUi.FormFieldFiller.prototype, {
|
|
|
|
bind: function bind() {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.unbind();
|
|
|
|
this.source.on('keyup.viewsUi change.viewsUi', this.populate);
|
|
|
|
this.target.on('focus.viewsUi', this.unbind);
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
getTransliterated: function getTransliterated() {
|
2014-01-27 21:41:32 +00:00
|
|
|
var from = this.source.val();
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (this.exclude) {
|
|
|
|
from = from.toLowerCase().replace(this.exclude, this.replace);
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-04-16 15:53:07 +00:00
|
|
|
return from;
|
2014-01-27 21:41:32 +00:00
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
_populate: function _populate() {
|
2014-01-27 21:41:32 +00:00
|
|
|
var transliterated = this.getTransliterated();
|
2014-04-16 15:53:07 +00:00
|
|
|
var suffix = this.suffix;
|
2014-07-02 18:48:06 +00:00
|
|
|
this.target.each(function (i) {
|
2014-04-16 15:53:07 +00:00
|
|
|
var maxlength = $(this).attr('maxlength') - suffix.length;
|
|
|
|
$(this).val(transliterated.substr(0, maxlength) + suffix);
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
_unbind: function _unbind() {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.source.off('keyup.viewsUi change.viewsUi', this.populate);
|
|
|
|
this.target.off('focus.viewsUi', this.unbind);
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
rebind: function rebind($fields) {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.target = $fields;
|
|
|
|
this.bind();
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
|
|
|
Drupal.behaviors.addItemForm = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
var $form = $context;
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (!$context.is('form[id^="views-ui-add-handler-form"]')) {
|
|
|
|
$form = $context.find('form[id^="views-ui-add-handler-form"]');
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($form.once('views-ui-add-handler-form').length) {
|
|
|
|
new Drupal.viewsUi.AddItemForm($form);
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.viewsUi.AddItemForm = function ($form) {
|
|
|
|
this.$form = $form;
|
|
|
|
this.$form.find('.views-filterable-options :checkbox').on('click', $.proxy(this.handleCheck, this));
|
|
|
|
this.$selected_div = this.$form.find('.views-selected-options').parent();
|
|
|
|
this.$selected_div.hide();
|
|
|
|
this.checkedItems = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.viewsUi.AddItemForm.prototype.handleCheck = function (event) {
|
|
|
|
var $target = $(event.target);
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
var label = $.trim($target.closest('td').next().html());
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($target.is(':checked')) {
|
|
|
|
this.$selected_div.show().css('display', 'block');
|
|
|
|
this.checkedItems.push(label);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
var position = $.inArray(label, this.checkedItems);
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
for (var i = 0; i < this.checkedItems.length; i++) {
|
|
|
|
if (i === position) {
|
|
|
|
this.checkedItems.splice(i, 1);
|
|
|
|
i--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (this.checkedItems.length === 0) {
|
|
|
|
this.$selected_div.hide();
|
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
this.refreshCheckedItems();
|
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi.AddItemForm.prototype.refreshCheckedItems = function () {
|
2017-05-19 22:12:53 +00:00
|
|
|
this.$selected_div.find('.views-selected-options').html(this.checkedItems.join(', ')).trigger('dialogContentResize');
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2013-08-07 06:27:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.viewsUiRenderAddViewButton = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2015-03-23 10:29:17 +00:00
|
|
|
var $menu = $(context).find('#views-display-menu-tabs').once('views-ui-render-add-view-button');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (!$menu.length) {
|
|
|
|
return;
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2020-01-30 09:08:38 +00:00
|
|
|
var $addDisplayDropdown = $("<li class=\"add\"><a href=\"#\"><span class=\"icon add\"></span>".concat(Drupal.t('Add'), "</a><ul class=\"action-list\" style=\"display:none;\"></ul></li>"));
|
2014-01-27 21:41:32 +00:00
|
|
|
var $displayButtons = $menu.nextAll('input.add-display').detach();
|
2017-05-19 22:12:53 +00:00
|
|
|
$displayButtons.appendTo($addDisplayDropdown.find('.action-list')).wrap('<li>').parent().eq(0).addClass('first').end().eq(-1).addClass('last');
|
2014-01-27 21:41:32 +00:00
|
|
|
$displayButtons.each(function () {
|
|
|
|
var label = $(this).val();
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (label.substr(0, 4) === 'Add ') {
|
|
|
|
$(this).val(label.substr(4));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$addDisplayDropdown.appendTo($menu);
|
|
|
|
$menu.find('li.add > a').on('click', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
var $trigger = $(this);
|
|
|
|
Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu($trigger);
|
|
|
|
});
|
|
|
|
$('li.add', $menu).on('mouseleave', function (event) {
|
|
|
|
var $this = $(this);
|
|
|
|
var $trigger = $this.children('a[href="#"]');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($this.children('.action-list').is(':visible')) {
|
|
|
|
Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu($trigger);
|
|
|
|
}
|
|
|
|
});
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu = function ($trigger) {
|
|
|
|
$trigger.parent().toggleClass('open');
|
|
|
|
$trigger.next().slideToggle('fast');
|
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.behaviors.viewsUiSearchOptions = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
var $form = $context;
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (!$context.is('form[id^="views-ui-add-handler-form"]')) {
|
|
|
|
$form = $context.find('form[id^="views-ui-add-handler-form"]');
|
|
|
|
}
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($form.once('views-ui-filter-options').length) {
|
|
|
|
new Drupal.viewsUi.OptionsSearch($form);
|
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi.OptionsSearch = function ($form) {
|
|
|
|
this.$form = $form;
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
this.$form.on('click', 'td.title', function (event) {
|
|
|
|
var $target = $(event.currentTarget);
|
|
|
|
$target.closest('tr').find('input').trigger('click');
|
|
|
|
});
|
|
|
|
var searchBoxSelector = '[data-drupal-selector="edit-override-controls-options-search"]';
|
|
|
|
var controlGroupSelector = '[data-drupal-selector="edit-override-controls-group"]';
|
2020-01-30 09:08:38 +00:00
|
|
|
this.$form.on('formUpdated', "".concat(searchBoxSelector, ",").concat(controlGroupSelector), $.proxy(this.handleFilter, this));
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
this.$searchBox = this.$form.find(searchBoxSelector);
|
|
|
|
this.$controlGroup = this.$form.find(controlGroupSelector);
|
2014-01-27 21:41:32 +00:00
|
|
|
this.options = this.getOptions(this.$form.find('.filterable-option'));
|
|
|
|
this.$searchBox.on('keypress', function (event) {
|
|
|
|
if (event.which === 13) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
$.extend(Drupal.viewsUi.OptionsSearch.prototype, {
|
|
|
|
getOptions: function getOptions($allOptions) {
|
2020-01-30 09:08:38 +00:00
|
|
|
var $title;
|
|
|
|
var $description;
|
|
|
|
var $option;
|
2014-01-27 21:41:32 +00:00
|
|
|
var options = [];
|
|
|
|
var length = $allOptions.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2015-04-19 15:30:43 +00:00
|
|
|
for (var i = 0; i < length; i++) {
|
2014-01-27 21:41:32 +00:00
|
|
|
$option = $($allOptions[i]);
|
2017-03-14 10:55:40 +00:00
|
|
|
$title = $option.find('.title');
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
$description = $option.find('.description');
|
2014-01-27 21:41:32 +00:00
|
|
|
options[i] = {
|
2020-01-30 09:08:38 +00:00
|
|
|
searchText: "".concat($title.text().toLowerCase(), " ").concat($description.text().toLowerCase()),
|
2015-08-07 14:08:23 +00:00
|
|
|
$div: $option
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
return options;
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
handleFilter: function handleFilter(event) {
|
2015-03-21 14:10:16 +00:00
|
|
|
var search = this.$searchBox.val().toLowerCase();
|
|
|
|
var words = search.split(' ');
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
var group = this.$controlGroup.val();
|
|
|
|
this.options.forEach(function (option) {
|
|
|
|
function hasWord(word) {
|
|
|
|
return option.searchText.indexOf(word) !== -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
var found = true;
|
2017-05-19 22:12:53 +00:00
|
|
|
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
if (search) {
|
|
|
|
found = words.every(hasWord);
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
if (found && group !== 'all') {
|
|
|
|
found = option.$div.hasClass(group);
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
Issue #1832862 by jerdavis, nlisgo, Zekvyrin, Maouna, nod_, royal121, tadityar, Lendude, dawehner, tim.plunkett, B_man, damiankloip, ohthehugemanatee, YesCT, Bojhan, xjm, dajjen, yoroy, lisarex, penyaskito, metzlerd, veronicanerak: Make views add field scannable
2015-10-05 22:03:30 +00:00
|
|
|
|
|
|
|
option.$div.toggle(found);
|
|
|
|
});
|
|
|
|
$(event.target).trigger('dialogContentResize');
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
Drupal.behaviors.viewsUiPreview = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2015-01-30 10:59:57 +00:00
|
|
|
var $contextualFiltersBucket = $(context).find('.views-display-column .views-ui-display-tab-bucket.argument');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($contextualFiltersBucket.length === 0) {
|
|
|
|
return;
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
var $contextualFilters = $contextualFiltersBucket.find('.views-display-setting a');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($contextualFilters.length) {
|
|
|
|
$('#preview-args').parent().show();
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
$('#preview-args').parent().hide();
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($('#edit-displays-live-preview').once('edit-displays-live-preview').is(':checked')) {
|
|
|
|
$('#preview-submit').once('edit-displays-live-preview').trigger('click');
|
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
Drupal.behaviors.viewsUiRearrangeFilter = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2014-01-27 21:41:32 +00:00
|
|
|
if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') {
|
|
|
|
return;
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters');
|
2015-09-20 16:57:36 +00:00
|
|
|
var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($table.length) {
|
|
|
|
new Drupal.viewsUi.RearrangeFilterHandler($table, $operator);
|
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi.RearrangeFilterHandler = function ($table, $operator) {
|
|
|
|
this.table = $table;
|
|
|
|
this.operator = $operator;
|
|
|
|
this.hasGroupOperator = this.operator.length > 0;
|
|
|
|
this.draggableRows = $table.find('.draggable');
|
2020-09-21 21:23:51 +00:00
|
|
|
this.addGroupButton = $('#views-add-group');
|
|
|
|
this.removeGroupButtons = $table.find('.views-remove-group');
|
2014-01-27 21:41:32 +00:00
|
|
|
this.insertAddRemoveFilterGroupLinks();
|
|
|
|
|
|
|
|
if (this.hasGroupOperator) {
|
|
|
|
this.dropdowns = this.duplicateGroupsOperator();
|
|
|
|
this.syncGroupsOperators();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.modifyTableDrag();
|
|
|
|
this.redrawOperatorLabels();
|
2017-05-19 22:12:53 +00:00
|
|
|
$table.find('.views-group-title select').once('views-rearrange-filter-handler').on('change.views-rearrange-filter-handler', $.proxy(this, 'redrawOperatorLabels'));
|
|
|
|
$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'));
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
$.extend(Drupal.viewsUi.RearrangeFilterHandler.prototype, {
|
|
|
|
insertAddRemoveFilterGroupLinks: function insertAddRemoveFilterGroupLinks() {
|
2020-01-30 09:08:38 +00:00
|
|
|
$("<ul class=\"action-links\"><li><a id=\"views-add-group-link\" href=\"#\">".concat(this.addGroupButton.val(), "</a></li></ul>")).prependTo(this.table.parent()).once('views-rearrange-filter-handler').find('#views-add-group-link').on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton'));
|
2020-01-28 13:12:54 +00:00
|
|
|
var length = this.removeGroupButtons.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
var i;
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
var $removeGroupButton = $(this.removeGroupButtons[i]);
|
|
|
|
var buttonId = $removeGroupButton.attr('id');
|
2020-01-30 09:08:38 +00:00
|
|
|
$("<a href=\"#\" class=\"views-remove-group-link\">".concat(Drupal.t('Remove group'), "</a>")).insertBefore($removeGroupButton).once('views-rearrange-filter-handler').on('click.views-rearrange-filter-handler', {
|
|
|
|
buttonId: buttonId
|
|
|
|
}, $.proxy(this, 'clickRemoveGroupButton'));
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
clickAddGroupButton: function clickAddGroupButton(event) {
|
2016-11-10 10:32:59 +00:00
|
|
|
this.addGroupButton.trigger('mousedown');
|
2014-01-27 21:41:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
clickRemoveGroupButton: function clickRemoveGroupButton(event) {
|
2020-01-30 09:08:38 +00:00
|
|
|
this.table.find("#".concat(event.data.buttonId)).trigger('mousedown');
|
2014-01-27 21:41:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
duplicateGroupsOperator: function duplicateGroupsOperator() {
|
2020-01-30 09:08:38 +00:00
|
|
|
var newRow;
|
|
|
|
var titleRow;
|
Issue #2168893 by marthinal, euphoric_mv, lauriii, Elijah Lynn, nod_, blueminds, jhedstrom, joelpittet, dawehner, tim.plunkett, YesCT: Views filters groups adding and removing is broken
2015-05-26 09:53:31 +00:00
|
|
|
var titleRows = $('tr.views-group-title').once('duplicateGroupsOperator');
|
|
|
|
|
|
|
|
if (!titleRows.length) {
|
|
|
|
return this.operator;
|
|
|
|
}
|
2012-08-28 22:55:51 +00:00
|
|
|
|
2014-07-13 20:29:09 +00:00
|
|
|
this.operator.find('label').add('div.description').addClass('visually-hidden');
|
2014-01-27 21:41:32 +00:00
|
|
|
this.operator.find('select').addClass('form-select');
|
2017-10-12 10:13:43 +00:00
|
|
|
var dropdowns = this.operator;
|
2014-01-27 21:41:32 +00:00
|
|
|
titleRow = $('tr#views-group-title-2');
|
|
|
|
newRow = $('<tr class="filter-group-operator-row"><td colspan="5"></td></tr>');
|
|
|
|
newRow.find('td').append(this.operator);
|
|
|
|
newRow.insertBefore(titleRow);
|
2015-04-19 15:30:43 +00:00
|
|
|
var length = titleRows.length;
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2015-04-19 15:30:43 +00:00
|
|
|
for (var i = 2; i < length; i++) {
|
2014-01-27 21:41:32 +00:00
|
|
|
titleRow = $(titleRows[i]);
|
|
|
|
var fakeOperator = this.operator.clone();
|
|
|
|
fakeOperator.attr('id', '');
|
|
|
|
newRow = $('<tr class="filter-group-operator-row"><td colspan="5"></td></tr>');
|
|
|
|
newRow.find('td').append(fakeOperator);
|
|
|
|
newRow.insertBefore(titleRow);
|
2016-02-26 04:22:06 +00:00
|
|
|
dropdowns.add(fakeOperator);
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return dropdowns;
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
syncGroupsOperators: function syncGroupsOperators() {
|
2014-01-27 21:41:32 +00:00
|
|
|
if (this.dropdowns.length < 2) {
|
|
|
|
return;
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
this.dropdowns.on('change', $.proxy(this, 'operatorChangeHandler'));
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
operatorChangeHandler: function operatorChangeHandler(event) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $target = $(event.target);
|
|
|
|
var operators = this.dropdowns.find('select').not($target);
|
|
|
|
operators.val($target.val());
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
modifyTableDrag: function modifyTableDrag() {
|
2014-01-27 21:41:32 +00:00
|
|
|
var tableDrag = Drupal.tableDrag['views-rearrange-filters'];
|
|
|
|
var filterHandler = this;
|
|
|
|
|
|
|
|
tableDrag.row.prototype.onSwap = function () {
|
|
|
|
if (filterHandler.hasGroupOperator) {
|
|
|
|
var thisRow = $(this.group);
|
|
|
|
var previousRow = thisRow.prev('tr');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (previousRow.length && !previousRow.hasClass('group-message') && !previousRow.hasClass('draggable')) {
|
|
|
|
var next = thisRow.next();
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (next.is('tr')) {
|
|
|
|
this.swap('after', next);
|
|
|
|
}
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
filterHandler.updateRowspans();
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
filterHandler.redrawOperatorLabels();
|
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
tableDrag.onDrop = function () {
|
|
|
|
var changeMarker = $(this.oldRowElement).find('.tabledrag-changed');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (changeMarker.length) {
|
|
|
|
var operatorLabel = changeMarker.prevAll('.views-operator-label');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (operatorLabel.length) {
|
|
|
|
operatorLabel.insertAfter(changeMarker);
|
|
|
|
}
|
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var groupRow = $(this.rowObject.element).prevAll('tr.group-message').get(0);
|
|
|
|
var groupName = groupRow.className.replace(/([^ ]+[ ]+)*group-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
|
|
|
var groupField = $('select.views-group-select', this.rowObject.element);
|
2020-01-30 09:08:38 +00:00
|
|
|
|
|
|
|
if (!groupField.is(".views-group-select-".concat(groupName))) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var oldGroupName = groupField.attr('class').replace(/([^ ]+[ ]+)*views-group-select-([^ ]+)([ ]+[^ ]+)*/, '$2');
|
2020-01-30 09:08:38 +00:00
|
|
|
groupField.removeClass("views-group-select-".concat(oldGroupName)).addClass("views-group-select-".concat(groupName));
|
2014-01-27 21:41:32 +00:00
|
|
|
groupField.val(groupName);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
redrawOperatorLabels: function redrawOperatorLabels() {
|
2014-01-27 21:41:32 +00:00
|
|
|
for (var i = 0; i < this.draggableRows.length; i++) {
|
|
|
|
var $draggableRow = $(this.draggableRows[i]);
|
2015-04-15 07:59:36 +00:00
|
|
|
var $firstCell = $draggableRow.find('td').eq(0);
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($firstCell.length) {
|
|
|
|
var operatorValue = $draggableRow.prevAll('.views-group-title').find('option:selected').html();
|
2020-01-30 09:08:38 +00:00
|
|
|
var operatorLabel = "<span class=\"views-operator-label\">".concat(operatorValue, "</span>");
|
2014-01-27 21:41:32 +00:00
|
|
|
var $nextRow = $draggableRow.nextAll(':visible').eq(0);
|
|
|
|
var $existingOperatorLabel = $firstCell.find('.views-operator-label');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($nextRow.hasClass('draggable')) {
|
|
|
|
if ($existingOperatorLabel.length) {
|
|
|
|
$existingOperatorLabel.replaceWith(operatorLabel);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
|
|
|
$firstCell.append(operatorLabel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$existingOperatorLabel.remove();
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
updateRowspans: function updateRowspans() {
|
2020-01-30 09:08:38 +00:00
|
|
|
var $row;
|
|
|
|
var $currentEmptyRow;
|
|
|
|
var draggableCount;
|
|
|
|
var $operatorCell;
|
2014-01-27 21:41:32 +00:00
|
|
|
var rows = $(this.table).find('tr');
|
|
|
|
var length = rows.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2015-04-19 15:30:43 +00:00
|
|
|
for (var i = 0; i < length; i++) {
|
2014-01-27 21:41:32 +00:00
|
|
|
$row = $(rows[i]);
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($row.hasClass('views-group-title')) {
|
|
|
|
$operatorCell = $row.find('td.group-operator');
|
|
|
|
draggableCount = 0;
|
|
|
|
$currentEmptyRow = $row.next('tr');
|
|
|
|
$currentEmptyRow.removeClass('group-populated').addClass('group-empty');
|
|
|
|
$operatorCell.attr('rowspan', 2);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else if ($row.hasClass('draggable') && $row.is(':visible')) {
|
2014-01-27 21:41:32 +00:00
|
|
|
draggableCount++;
|
|
|
|
$currentEmptyRow.removeClass('group-empty').addClass('group-populated');
|
|
|
|
$operatorCell.attr('rowspan', draggableCount + 1);
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
|
|
|
Drupal.behaviors.viewsFilterConfigSelectAll = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2015-06-22 13:16:58 +00:00
|
|
|
var $context = $(context);
|
2015-09-20 16:57:36 +00:00
|
|
|
var $selectAll = $context.find('.js-form-item-options-value-all').once('filterConfigSelectAll');
|
2015-06-22 13:16:58 +00:00
|
|
|
var $selectAllCheckbox = $selectAll.find('input[type=checkbox]');
|
2015-09-20 16:57:36 +00:00
|
|
|
var $checkboxes = $selectAll.closest('.form-checkboxes').find('.js-form-type-checkbox:not(.js-form-item-options-value-all) input[type="checkbox"]');
|
2015-06-22 13:16:58 +00:00
|
|
|
|
|
|
|
if ($selectAll.length) {
|
|
|
|
$selectAll.show();
|
|
|
|
$selectAllCheckbox.on('click', function () {
|
|
|
|
$checkboxes.prop('checked', $(this).is(':checked'));
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2015-06-22 13:16:58 +00:00
|
|
|
$checkboxes.on('click', function () {
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($(this).is('checked') === false) {
|
2015-06-22 13:16:58 +00:00
|
|
|
$selectAllCheckbox.prop('checked', false);
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
});
|
2015-06-22 13:16:58 +00:00
|
|
|
}
|
2009-05-17 11:16:51 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
Drupal.behaviors.viewsRemoveIconClass = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2015-03-23 10:29:17 +00:00
|
|
|
$(context).find('.dropbutton').once('dropbutton-icon').find('.icon').removeClass('icon');
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
Drupal.behaviors.viewsUiCheckboxify = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context, settings) {
|
2015-06-22 13:16:58 +00:00
|
|
|
var $buttons = $('[data-drupal-selector="edit-options-expose-button-button"], [data-drupal-selector="edit-options-group-button-button"]').once('views-ui-checkboxify');
|
2014-01-27 21:41:32 +00:00
|
|
|
var length = $buttons.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
var i;
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
new Drupal.viewsUi.Checkboxifier($buttons[i]);
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
Drupal.behaviors.viewsUiChangeDefaultWidget = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2015-06-11 22:43:33 +00:00
|
|
|
var $context = $(context);
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function changeDefaultWidget(event) {
|
|
|
|
if ($(event.target).prop('checked')) {
|
2015-06-11 22:43:33 +00:00
|
|
|
$context.find('input.default-radios').parent().hide();
|
|
|
|
$context.find('td.any-default-radios-row').parent().hide();
|
|
|
|
$context.find('input.default-checkboxes').parent().show();
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2015-06-11 22:43:33 +00:00
|
|
|
$context.find('input.default-checkboxes').parent().hide();
|
|
|
|
$context.find('td.any-default-radios-row').parent().show();
|
|
|
|
$context.find('input.default-radios').parent().show();
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2013-08-07 06:27:16 +00:00
|
|
|
}
|
2014-07-02 18:48:06 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
$context.find('input[name="options[group_info][multiple]"]').on('change', changeDefaultWidget).trigger('change');
|
2012-08-17 15:09:47 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2012-08-17 15:09:47 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi.Checkboxifier = function (button) {
|
|
|
|
this.$button = $(button);
|
|
|
|
this.$parent = this.$button.parent('div.views-expose, div.views-grouped');
|
|
|
|
this.$input = this.$parent.find('input:checkbox, input:radio');
|
|
|
|
this.$button.hide();
|
|
|
|
this.$parent.find('.exposed-description, .grouped-description').hide();
|
|
|
|
this.$input.on('click', $.proxy(this, 'clickHandler'));
|
|
|
|
};
|
2009-05-17 11:16:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.viewsUi.Checkboxifier.prototype.clickHandler = function (e) {
|
2017-05-19 22:12:53 +00:00
|
|
|
this.$button.trigger('click').trigger('submit');
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2013-08-07 06:27:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.viewsUiOverrideSelect = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2015-06-22 13:16:58 +00:00
|
|
|
$(context).find('[data-drupal-selector="edit-override-dropdown"]').once('views-ui-override-button-text').each(function () {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
var $submit = $context.find('[id^=edit-submit]');
|
2017-12-03 16:16:29 +00:00
|
|
|
var oldValue = $submit.val();
|
2017-05-19 22:12:53 +00:00
|
|
|
$submit.once('views-ui-override-button-text').on('mouseup', function () {
|
2017-12-03 16:16:29 +00:00
|
|
|
$(this).val(oldValue);
|
2017-05-19 22:12:53 +00:00
|
|
|
return true;
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
$(this).on('change', function () {
|
|
|
|
var $this = $(this);
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($this.val() === 'default') {
|
|
|
|
$submit.val(Drupal.t('Apply (all displays)'));
|
2017-05-19 22:12:53 +00:00
|
|
|
} else if ($this.val() === 'default_revert') {
|
2014-01-27 21:41:32 +00:00
|
|
|
$submit.val(Drupal.t('Revert to default'));
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
$submit.val(Drupal.t('Apply (this display)'));
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var $dialog = $context.closest('.ui-dialog-content');
|
|
|
|
$dialog.trigger('dialogButtonsChange');
|
2017-05-19 22:12:53 +00:00
|
|
|
}).trigger('change');
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Drupal.behaviors.viewsUiHandlerRemoveLink = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
$context.find('a.views-remove-link').once('views').on('click', function (event) {
|
|
|
|
var id = $(this).attr('id').replace('views-remove-link-', '');
|
2020-01-30 09:08:38 +00:00
|
|
|
$context.find("#views-row-".concat(id)).hide();
|
|
|
|
$context.find("#views-removed-".concat(id)).prop('checked', true);
|
2014-01-27 21:41:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
$context.find('a.display-remove-link').once('display').on('click', function (event) {
|
|
|
|
var id = $(this).attr('id').replace('display-remove-link-', '');
|
2020-01-30 09:08:38 +00:00
|
|
|
$context.find("#display-row-".concat(id)).hide();
|
|
|
|
$context.find("#display-removed-".concat(id)).prop('checked', true);
|
2014-01-27 21:41:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal, drupalSettings);
|