base.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. (function ($, Drupal, drupalSettings) {
  8. Drupal.Views = {};
  9. Drupal.Views.parseQueryString = function (query) {
  10. var args = {};
  11. var pos = query.indexOf('?');
  12. if (pos !== -1) {
  13. query = query.substring(pos + 1);
  14. }
  15. var pair = void 0;
  16. var pairs = query.split('&');
  17. for (var i = 0; i < pairs.length; i++) {
  18. pair = pairs[i].split('=');
  19. if (pair[0] !== 'q' && pair[1]) {
  20. args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
  21. }
  22. }
  23. return args;
  24. };
  25. Drupal.Views.parseViewArgs = function (href, viewPath) {
  26. var returnObj = {};
  27. var path = Drupal.Views.getPath(href);
  28. var viewHref = Drupal.url(viewPath).substring(drupalSettings.path.baseUrl.length);
  29. if (viewHref && path.substring(0, viewHref.length + 1) === viewHref + '/') {
  30. returnObj.view_args = decodeURIComponent(path.substring(viewHref.length + 1, path.length));
  31. returnObj.view_path = path;
  32. }
  33. return returnObj;
  34. };
  35. Drupal.Views.pathPortion = function (href) {
  36. var protocol = window.location.protocol;
  37. if (href.substring(0, protocol.length) === protocol) {
  38. href = href.substring(href.indexOf('/', protocol.length + 2));
  39. }
  40. return href;
  41. };
  42. Drupal.Views.getPath = function (href) {
  43. href = Drupal.Views.pathPortion(href);
  44. href = href.substring(drupalSettings.path.baseUrl.length, href.length);
  45. if (href.substring(0, 3) === '?q=') {
  46. href = href.substring(3, href.length);
  47. }
  48. var chars = ['#', '?', '&'];
  49. for (var i = 0; i < chars.length; i++) {
  50. if (href.indexOf(chars[i]) > -1) {
  51. href = href.substr(0, href.indexOf(chars[i]));
  52. }
  53. }
  54. return href;
  55. };
  56. })(jQuery, Drupal, drupalSettings);