Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,188 @@
/**
* @file
* Handles AJAX submission and response in Views UI.
*/
(function ($, Drupal, drupalSettings) {
"use strict";
/**
*
* @param {Drupal.Ajax} [ajax]
* @param {object} response
* @param {string} response.selector
* @param {number} [status]
*/
Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
$('.hilited').removeClass('hilited');
$(response.selector).addClass('hilited');
};
/**
*
* @param {Drupal.Ajax} [ajax]
* @param {object} response
* @param {bool} response.changed
* @param {number} [status]
*/
Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
$('div.views-edit-view div.form-actions').removeClass('js-hide');
if (response.changed) {
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
}
};
/**
*
* @param {Drupal.Ajax} [ajax]
* @param {object} [response]
* @param {number} [status]
*/
Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {
if ($('input#edit-displays-live-preview').is(':checked')) {
$('#preview-submit').trigger('click');
}
};
/**
*
* @param {Drupal.Ajax} [ajax]
* @param {object} response
* @param {string} response.siteName
* @param {string} response.title
* @param {number} [status]
*/
Drupal.AjaxCommands.prototype.viewsReplaceTitle = function (ajax, response, status) {
var doc = document;
// For the <title> element, make a best-effort attempt to replace the page
// title and leave the site name alone. If the theme doesn't use the site
// name in the <title> element, this will fail.
var oldTitle = doc.title;
// Escape the site name, in case it has special characters in it, so we can
// use it in our regex.
var escapedSiteName = response.siteName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var re = new RegExp('.+ (.) ' + escapedSiteName);
doc.title = oldTitle.replace(re, response.title + ' $1 ' + response.siteName);
$('h1.page-title').text(response.title);
};
/**
* Get rid of irritating tabledrag messages.
*
* @return {Array}
*/
Drupal.theme.tableDragChangedWarning = function () {
return [];
};
/**
* Trigger preview when the "live preview" checkbox is checked.
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.livePreview = {
attach: function (context) {
$('input#edit-displays-live-preview', context).once('views-ajax').on('click', function () {
if ($(this).is(':checked')) {
$('#preview-submit').trigger('click');
}
});
}
};
/**
* Sync preview display.
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.syncPreviewDisplay = {
attach: function (context) {
$("#views-tabset a").once('views-ajax').on('click', function () {
var href = $(this).attr('href');
// Cut of #views-tabset.
var display_id = href.substr(11);
// Set the form element.
$("#views-live-preview #preview-display-id").val(display_id);
});
}
};
/**
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.viewsAjax = {
collapseReplaced: false,
attach: function (context, settings) {
var base_element_settings = {
'event': 'click',
'progress': {'type': 'fullscreen'}
};
// Bind AJAX behaviors to all items showing the class.
$('a.views-ajax-link', context).once('views-ajax').each(function () {
var element_settings = base_element_settings;
element_settings.base = base;
element_settings.element = this;
// Set the URL to go to the anchor.
if ($(this).attr('href')) {
element_settings.url = $(this).attr('href');
}
var base = $(this).attr('id');
Drupal.ajax(element_settings);
});
$('div#views-live-preview a')
.once('views-ajax').each(function () {
// We don't bind to links without a URL.
if (!$(this).attr('href')) {
return true;
}
var element_settings = base_element_settings;
// Set the URL to go to the anchor.
element_settings.url = $(this).attr('href');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.base = base;
element_settings.element = this;
var base = $(this).attr('id');
Drupal.ajax(element_settings);
});
// Within a live preview, make exposed widget form buttons re-trigger the
// Preview button.
// @todo Revisit this after fixing Views UI to display a Preview outside
// of the main Edit form.
$('div#views-live-preview input[type=submit]')
.once('views-ajax').each(function (event) {
$(this).on('click', function () {
this.form.clk = this;
return true;
});
var element_settings = base_element_settings;
// Set the URL to go to the anchor.
element_settings.url = $(this.form).attr('action');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.event = 'click';
element_settings.base = base;
element_settings.element = this;
var base = $(this).attr('id');
Drupal.ajax(element_settings);
});
}
};
})(jQuery, Drupal, drupalSettings);

View file

@ -0,0 +1,52 @@
/**
* @file
* Views dialog behaviors.
*/
(function ($, Drupal, drupalSettings) {
"use strict";
function handleDialogResize(e) {
var $modal = $(e.currentTarget);
var $viewsOverride = $modal.find('[data-drupal-views-offset]');
var $scroll = $modal.find('[data-drupal-views-scroll]');
var offset = 0;
var modalHeight;
if ($scroll.length) {
// Add a class to do some styles adjustments.
$modal.closest('.views-ui-dialog').addClass('views-ui-dialog-scroll');
// Let scroll element take all the height available.
$scroll.css({overflow: 'visible', height: 'auto'});
modalHeight = $modal.height();
$viewsOverride.each(function () { offset += $(this).outerHeight(); });
// Take internal padding into account.
var scrollOffset = $scroll.outerHeight() - $scroll.height();
$scroll.height(modalHeight - offset - scrollOffset);
// Reset scrolling properties.
$modal.css('overflow', 'hidden');
$scroll.css('overflow', 'auto');
}
}
/**
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.viewsModalContent = {
attach: function (context) {
$('body').once('viewsDialog').on('dialogContentResize.viewsDialog', '.ui-dialog-content', handleDialogResize);
// When expanding details, make sure the modal is resized.
$(context).find('.scroll').once('detailsUpdate').on('click', 'summary', function (e) {
$(e.currentTarget).trigger('dialogContentResize');
});
},
detach: function (context, settings, trigger) {
if (trigger === 'unload') {
$('body').removeOnce('viewsDialog').off('.viewsDialog');
}
}
};
})(jQuery, Drupal, drupalSettings);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,51 @@
/**
* @file
* Views listing behaviors.
*/
(function ($, Drupal) {
"use strict";
/**
* Filters the view listing tables by a text input search string.
*
* Text search input: input.views-filter-text
* Target table: input.views-filter-text[data-table]
* Source text: .views-table-filter-text-source
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.viewTableFilterByText = {
attach: function (context, settings) {
var $input = $('input.views-filter-text').once('views-filter-text');
var $table = $($input.attr('data-table'));
var $rows;
function filterViewList(e) {
var query = $(e.target).val().toLowerCase();
function showViewRow(index, row) {
var $row = $(row);
var $sources = $row.find('.views-table-filter-text-source');
var textMatch = $sources.text().toLowerCase().indexOf(query) !== -1;
$row.closest('tr').toggle(textMatch);
}
// Filter if the length of the query is at least 2 characters.
if (query.length >= 2) {
$rows.each(showViewRow);
}
else {
$rows.show();
}
}
if ($table.length) {
$rows = $table.find('tbody tr');
$input.on('keyup', filterViewList);
}
}
};
}(jQuery, Drupal));