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