comparison core/modules/views/js/base.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
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.Views = {};
10
11 Drupal.Views.parseQueryString = function (query) {
12 var args = {};
13 var pos = query.indexOf('?');
14 if (pos !== -1) {
15 query = query.substring(pos + 1);
16 }
17 var pair = void 0;
18 var pairs = query.split('&');
19 for (var i = 0; i < pairs.length; i++) {
20 pair = pairs[i].split('=');
21
22 if (pair[0] !== 'q' && pair[1]) {
23 args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
24 }
25 }
26 return args;
27 };
28
29 Drupal.Views.parseViewArgs = function (href, viewPath) {
30 var returnObj = {};
31 var path = Drupal.Views.getPath(href);
32
33 var viewHref = Drupal.url(viewPath).substring(drupalSettings.path.baseUrl.length);
34
35 if (viewHref && path.substring(0, viewHref.length + 1) === viewHref + '/') {
36 returnObj.view_args = decodeURIComponent(path.substring(viewHref.length + 1, path.length));
37 returnObj.view_path = path;
38 }
39 return returnObj;
40 };
41
42 Drupal.Views.pathPortion = function (href) {
43 var protocol = window.location.protocol;
44 if (href.substring(0, protocol.length) === protocol) {
45 href = href.substring(href.indexOf('/', protocol.length + 2));
46 }
47 return href;
48 };
49
50 Drupal.Views.getPath = function (href) {
51 href = Drupal.Views.pathPortion(href);
52 href = href.substring(drupalSettings.path.baseUrl.length, href.length);
53
54 if (href.substring(0, 3) === '?q=') {
55 href = href.substring(3, href.length);
56 }
57 var chars = ['#', '?', '&'];
58 for (var i = 0; i < chars.length; i++) {
59 if (href.indexOf(chars[i]) > -1) {
60 href = href.substr(0, href.indexOf(chars[i]));
61 }
62 }
63 return href;
64 };
65 })(jQuery, Drupal, drupalSettings);