Skip to content
Snippets Groups Projects
Commit 935f3790 authored by Brian Canini's avatar Brian Canini
Browse files

module update - updating to ajax history module from 8.x-1.0 > 8.x-1.1

parent ebaa40d1
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "562988aa02aa13014da7f5532c594855",
"content-hash": "280dc9c0811d00839ceb8706622da5f1",
"packages": [
{
"name": "alchemy/zippy",
......@@ -6952,17 +6952,17 @@
},
{
"name": "drupal/views_ajax_history",
"version": "1.0.0",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/views_ajax_history.git",
"reference": "8.x-1.0"
"reference": "8.x-1.1"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/views_ajax_history-8.x-1.0.zip",
"reference": "8.x-1.0",
"shasum": "ef23bf3a8e1c902b98d4556203dd8fc7068dfcb5"
"url": "https://ftp.drupal.org/files/projects/views_ajax_history-8.x-1.1.zip",
"reference": "8.x-1.1",
"shasum": "dd5f5256e139dff1371a109959dde70d593d4d1a"
},
"require": {
"drupal/core": "*"
......@@ -6973,8 +6973,8 @@
"dev-1.x": "1.x-dev"
},
"drupal": {
"version": "8.x-1.0",
"datestamp": "1535376480",
"version": "8.x-1.1",
"datestamp": "1559296088",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
......@@ -7006,7 +7006,7 @@
"description": "Add bookmarking abilities to AJAX Views.",
"homepage": "https://www.drupal.org/project/views_ajax_history",
"support": {
"source": "http://cgit.drupalcode.org/views_ajax_history"
"source": "https://git.drupalcode.org/project/views_ajax_history"
}
},
{
......
......@@ -7176,18 +7176,18 @@
},
{
"name": "drupal/views_ajax_history",
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/views_ajax_history.git",
"reference": "8.x-1.0"
"reference": "8.x-1.1"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/views_ajax_history-8.x-1.0.zip",
"reference": "8.x-1.0",
"shasum": "ef23bf3a8e1c902b98d4556203dd8fc7068dfcb5"
"url": "https://ftp.drupal.org/files/projects/views_ajax_history-8.x-1.1.zip",
"reference": "8.x-1.1",
"shasum": "dd5f5256e139dff1371a109959dde70d593d4d1a"
},
"require": {
"drupal/core": "*"
......@@ -7198,8 +7198,8 @@
"dev-1.x": "1.x-dev"
},
"drupal": {
"version": "8.x-1.0",
"datestamp": "1535376480",
"version": "8.x-1.1",
"datestamp": "1559296088",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
......@@ -7232,7 +7232,7 @@
"description": "Add bookmarking abilities to AJAX Views.",
"homepage": "https://www.drupal.org/project/views_ajax_history",
"support": {
"source": "http://cgit.drupalcode.org/views_ajax_history"
"source": "https://git.drupalcode.org/project/views_ajax_history"
}
},
{
......
/**
* @file
* Contains views_ajax_history.js.
*/
(function ($, Drupal, drupalSettings) {
// Need to keep this to check if there are extra parameters in the original URL.
var original = {
path: window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '') + window.location.pathname,
path: window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '') + window.location.pathname,
// @TODO integrate #1359798 without breaking history.js
query: window.location.search || ''
};
......@@ -34,7 +39,7 @@
};
/**
* Modification of Drupal.Views.parseQueryString() to allow extracting multivalues fields
* Modification of Drupal.Views.parseQueryString() to allow extracting multivalues fields.
*
* @param query
* String, either a full url or just the query string.
......@@ -47,19 +52,19 @@
}
var pairs = query.split('&');
var pair, key, value;
for(var i in pairs) {
for (var i in pairs) {
if (typeof(pairs[i]) == 'string') {
pair = pairs[i].split('=');
// Ignore the 'q' path argument, if present.
if (pair[0] != 'q' && pair[1]) {
key = decodeURIComponent(pair[0].replace(/\+/g, ' '));
value = decodeURIComponent(pair[1].replace(/\+/g, ' '));
// field name ends with [], it's multivalues
// Field name ends with [], it's multivalues.
if (/\[\]$/.test(key)) {
if (!(key in args)) {
args[key] = [value];
}
// don't duplicate values
// Don't duplicate values.
else if (!$.inArray(value, args[key]) !== -1) {
args[key].push(value);
}
......@@ -74,7 +79,7 @@
};
/**
* Strip views values and duplicates from URL
* Strip views values and duplicates from URL.
*
* @param url
* String with the full URL to clean up.
......@@ -94,17 +99,17 @@
}
$.each(args, function (name, value) {
// use values from viewArgs if they exists
// Use values from viewArgs if they exists.
if (name in viewArgs) {
value = viewArgs[name];
}
if ($.isArray(value)) {
$.merge(query, $.map(value, function (sub) {
return name + '=' + sub;
return name + '=' + encodeURIComponent(sub);
}));
}
else {
query.push(name + '=' + value);
query.push(name + '=' + encodeURIComponent(value));
}
});
......@@ -113,14 +118,14 @@
};
/**
* Parse a URL query string
* Parse a URL query string.
*
* @param queryString
* String containing the query to parse.
*/
var parseQuery = function(queryString) {
var parseQuery = function (queryString) {
var query = {};
$.map(queryString.split('&'), function(val) {
$.map(queryString.split('&'), function (val) {
var s = val.split('=');
query[s[0]] = s[1];
});
......@@ -190,7 +195,7 @@
};
/**
* Override beforeSerialize to handle click on pager links
* Override beforeSerialize to handle click on pager links.
*
* @param $element
* jQuery DOM element
......@@ -199,7 +204,7 @@
Drupal.Ajax.prototype.beforeSerialize = function (element, options) {
// Check that we handle a click on a link, not a form submission.
if (options.data.view_name && element && $(element).is('a')) {
addState(options, $(element).attr('href'));
addState(options, window.location.href);
}
// Call the original Drupal method with the right context.
......@@ -221,26 +226,55 @@
var url = original.path + '?' + element.formSerialize();
var currentQuery = parseQueryString(window.location.href);
// copy selected values in history state
// Remove the page number from the query string, as a new filter has been
// applied and should return new results.
if ($.inArray("page", Object.keys(currentQuery)) !== -1) {
delete currentQuery.page;
}
// Copy selected values in history state.
$.each(form_values, function () {
// field name ending with [] is a multi value field
// Field name ending with [] is a multi value field.
if (/\[\]$/.test(this.name)) {
if (!options.data[this.name]) {
options.data[this.name] = [];
}
options.data[this.name].push(this.value);
}
// regular field
// Regular field.
else {
options.data[this.name] = this.value;
}
// Remove exposed data from the current query to leave behind any
// non exposed form related query vars
});
// Remove exposed data from the current query to leave behind any
// non exposed form related query vars.
element.find('[name]').each(function () {
if (currentQuery[this.name]) {
delete currentQuery[this.name];
}
});
// If the exposed form has checkboxes, we need to check if these are
// unchecked and if so, remove them from the url
element.find('input[type="checkbox"]').each(function (key, value) {
if (!form_values[this.name]) {
if (currentQuery[this.name]) {
delete currentQuery[this.name];
}
else if (options.data[this.name]) {
delete options.data[this.name];
}
}
});
// If the exposed form has a multiple select.
element.find('.form-select[multiple=multiple]').each(function (key, value) {
if ($(value).val().length === 0) {
delete options.data[this.name];
delete currentQuery[this.name];
}
});
url += (/\?/.test(url) ? '&' : '?') + $.param(currentQuery);
addState(options, url);
}
......@@ -262,10 +296,9 @@
if (data.view_name && options.type !== 'GET') {
// Override the URL to not contain any fields that were submitted.
options.url = drupalSettings.views.ajax_path + '?' + Drupal.ajax.WRAPPER_FORMAT + '=drupal_ajax';
// Call the original Drupal method with the right context.
beforeSend.apply(this, arguments);
}
// Call the original Drupal method with the right context.
beforeSend.apply(this, arguments);
}
})(jQuery, Drupal, drupalSettings);
......@@ -4,10 +4,10 @@ description: 'Add bookmarking abilities to AJAX Views.'
# core: 8.x
package: Views
dependencies:
- views
- drupal:views
# Information added by Drupal.org packaging script on 2018-08-27
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2019-05-31
version: '8.x-1.1'
core: '8.x'
project: 'views_ajax_history'
datestamp: 1535376604
datestamp: 1559296090
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment