annotate core/modules/views_ui/js/ajax.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 1fec387a4317
children
rev   line source
Chris@0 1 /**
Chris@0 2 * DO NOT EDIT THIS FILE.
Chris@0 3 * See the following change record for more information,
Chris@0 4 * https://www.drupal.org/node/2815083
Chris@0 5 * @preserve
Chris@0 6 **/
Chris@0 7
Chris@0 8 (function ($, Drupal, drupalSettings) {
Chris@0 9 Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
Chris@0 10 $('.hilited').removeClass('hilited');
Chris@0 11 $(response.selector).addClass('hilited');
Chris@0 12 };
Chris@0 13
Chris@0 14 Drupal.AjaxCommands.prototype.viewsSetForm = function (ajax, response, status) {
Chris@0 15 var $form = $('.js-views-ui-dialog form');
Chris@0 16
Chris@14 17 var $submitButtons = $form.find('input[type=submit].js-form-submit, button.js-form-submit').once('views-ajax-submit');
Chris@14 18 $submitButtons.on('click mousedown', function () {
Chris@0 19 this.form.clk = this;
Chris@0 20 });
Chris@0 21 $form.once('views-ajax-submit').each(function () {
Chris@0 22 var $form = $(this);
Chris@14 23 var elementSettings = {
Chris@0 24 url: response.url,
Chris@0 25 event: 'submit',
Chris@0 26 base: $form.attr('id'),
Chris@0 27 element: this
Chris@0 28 };
Chris@14 29 var ajaxForm = Drupal.ajax(elementSettings);
Chris@0 30 ajaxForm.$form = $form;
Chris@0 31 });
Chris@0 32 };
Chris@0 33
Chris@0 34 Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
Chris@0 35 $('div.views-edit-view div.form-actions').removeClass('js-hide');
Chris@0 36 if (response.changed) {
Chris@0 37 $('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
Chris@0 38 }
Chris@0 39 };
Chris@0 40
Chris@0 41 Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {
Chris@0 42 if ($('input#edit-displays-live-preview').is(':checked')) {
Chris@0 43 $('#preview-submit').trigger('click');
Chris@0 44 }
Chris@0 45 };
Chris@0 46
Chris@0 47 Drupal.AjaxCommands.prototype.viewsReplaceTitle = function (ajax, response, status) {
Chris@0 48 var doc = document;
Chris@0 49
Chris@0 50 var oldTitle = doc.title;
Chris@0 51
Chris@0 52 var escapedSiteName = response.siteName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
Chris@0 53 var re = new RegExp('.+ (.) ' + escapedSiteName);
Chris@0 54 doc.title = oldTitle.replace(re, response.title + ' $1 ' + response.siteName);
Chris@0 55
Chris@0 56 $('h1.page-title').text(response.title);
Chris@0 57 };
Chris@0 58
Chris@0 59 Drupal.theme.tableDragChangedWarning = function () {
Chris@0 60 return [];
Chris@0 61 };
Chris@0 62
Chris@0 63 Drupal.behaviors.livePreview = {
Chris@0 64 attach: function attach(context) {
Chris@0 65 $('input#edit-displays-live-preview', context).once('views-ajax').on('click', function () {
Chris@0 66 if ($(this).is(':checked')) {
Chris@0 67 $('#preview-submit').trigger('click');
Chris@0 68 }
Chris@0 69 });
Chris@0 70 }
Chris@0 71 };
Chris@0 72
Chris@0 73 Drupal.behaviors.syncPreviewDisplay = {
Chris@0 74 attach: function attach(context) {
Chris@0 75 $('#views-tabset a').once('views-ajax').on('click', function () {
Chris@0 76 var href = $(this).attr('href');
Chris@0 77
Chris@14 78 var displayId = href.substr(11);
Chris@0 79
Chris@14 80 $('#views-live-preview #preview-display-id').val(displayId);
Chris@0 81 });
Chris@0 82 }
Chris@0 83 };
Chris@0 84
Chris@0 85 Drupal.behaviors.viewsAjax = {
Chris@0 86 collapseReplaced: false,
Chris@0 87 attach: function attach(context, settings) {
Chris@14 88 var baseElementSettings = {
Chris@0 89 event: 'click',
Chris@0 90 progress: { type: 'fullscreen' }
Chris@0 91 };
Chris@0 92
Chris@0 93 $('a.views-ajax-link', context).once('views-ajax').each(function () {
Chris@14 94 var elementSettings = baseElementSettings;
Chris@14 95 elementSettings.base = $(this).attr('id');
Chris@14 96 elementSettings.element = this;
Chris@0 97
Chris@0 98 if ($(this).attr('href')) {
Chris@14 99 elementSettings.url = $(this).attr('href');
Chris@0 100 }
Chris@14 101 Drupal.ajax(elementSettings);
Chris@0 102 });
Chris@0 103
Chris@0 104 $('div#views-live-preview a').once('views-ajax').each(function () {
Chris@0 105 if (!$(this).attr('href')) {
Chris@0 106 return true;
Chris@0 107 }
Chris@0 108
Chris@14 109 var elementSettings = baseElementSettings;
Chris@0 110
Chris@14 111 elementSettings.url = $(this).attr('href');
Chris@14 112 if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') {
Chris@0 113 return true;
Chris@0 114 }
Chris@0 115
Chris@14 116 elementSettings.wrapper = 'views-preview-wrapper';
Chris@14 117 elementSettings.method = 'replaceWith';
Chris@14 118 elementSettings.base = $(this).attr('id');
Chris@14 119 elementSettings.element = this;
Chris@14 120 Drupal.ajax(elementSettings);
Chris@0 121 });
Chris@0 122
Chris@0 123 $('div#views-live-preview input[type=submit]').once('views-ajax').each(function (event) {
Chris@0 124 $(this).on('click', function () {
Chris@0 125 this.form.clk = this;
Chris@0 126 return true;
Chris@0 127 });
Chris@14 128 var elementSettings = baseElementSettings;
Chris@0 129
Chris@14 130 elementSettings.url = $(this.form).attr('action');
Chris@14 131 if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') {
Chris@0 132 return true;
Chris@0 133 }
Chris@0 134
Chris@14 135 elementSettings.wrapper = 'views-preview-wrapper';
Chris@14 136 elementSettings.method = 'replaceWith';
Chris@14 137 elementSettings.event = 'click';
Chris@14 138 elementSettings.base = $(this).attr('id');
Chris@14 139 elementSettings.element = this;
Chris@0 140
Chris@14 141 Drupal.ajax(elementSettings);
Chris@0 142 });
Chris@0 143 }
Chris@0 144 };
Chris@0 145 })(jQuery, Drupal, drupalSettings);