X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews%2Fjs%2Fbase.js;h=be522cf5aa24e985f482363fa7670972fea2e8dd;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=cca3be4ddecd0fec3cdb4b47881a7e4a55e3e9c5;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/views/js/base.js b/web/core/modules/views/js/base.js index cca3be4dd..be522cf5a 100644 --- a/web/core/modules/views/js/base.js +++ b/web/core/modules/views/js/base.js @@ -1,37 +1,24 @@ /** - * @file - * Some basic behaviors and utility functions for Views. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function ($, Drupal, drupalSettings) { - - 'use strict'; - - /** - * @namespace - */ Drupal.Views = {}; - /** - * Helper function to parse a querystring. - * - * @param {string} query - * The querystring to parse. - * - * @return {object} - * A map of query parameters. - */ Drupal.Views.parseQueryString = function (query) { var args = {}; var pos = query.indexOf('?'); if (pos !== -1) { query = query.substring(pos + 1); } - var pair; + var pair = void 0; var pairs = query.split('&'); for (var i = 0; i < pairs.length; i++) { pair = pairs[i].split('='); - // Ignore the 'q' path argument, if present. + if (pair[0] !== 'q' && pair[1]) { args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); } @@ -39,23 +26,12 @@ return args; }; - /** - * Helper function to return a view's arguments based on a path. - * - * @param {string} href - * The href to check. - * @param {string} viewPath - * The views path to check. - * - * @return {object} - * An object containing `view_args` and `view_path`. - */ Drupal.Views.parseViewArgs = function (href, viewPath) { var returnObj = {}; var path = Drupal.Views.getPath(href); - // Get viewPath url without baseUrl portion. + var viewHref = Drupal.url(viewPath).substring(drupalSettings.path.baseUrl.length); - // Ensure we have a correct path. + if (viewHref && path.substring(0, viewHref.length + 1) === viewHref + '/') { returnObj.view_args = decodeURIComponent(path.substring(viewHref.length + 1, path.length)); returnObj.view_path = path; @@ -63,38 +39,18 @@ return returnObj; }; - /** - * Strip off the protocol plus domain from an href. - * - * @param {string} href - * The href to strip. - * - * @return {string} - * The href without the protocol and domain. - */ Drupal.Views.pathPortion = function (href) { - // Remove e.g. http://example.com if present. var protocol = window.location.protocol; if (href.substring(0, protocol.length) === protocol) { - // 2 is the length of the '//' that normally follows the protocol. href = href.substring(href.indexOf('/', protocol.length + 2)); } return href; }; - /** - * Return the Drupal path portion of an href. - * - * @param {string} href - * The href to check. - * - * @return {string} - * An internal path. - */ Drupal.Views.getPath = function (href) { href = Drupal.Views.pathPortion(href); href = href.substring(drupalSettings.path.baseUrl.length, href.length); - // 3 is the length of the '?q=' added to the url without clean urls. + if (href.substring(0, 3) === '?q=') { href = href.substring(3, href.length); } @@ -106,5 +62,4 @@ } return href; }; - -})(jQuery, Drupal, drupalSettings); +})(jQuery, Drupal, drupalSettings); \ No newline at end of file