Sha256: 31ebd6eb1f3fe69b029175c2360964c50463881202a730af2d5ed087cf0da7b2

Contents?: true

Size: 945 Bytes

Versions: 26

Compression:

Stored size: 945 Bytes

Contents

function hasTurbolinks() {
  return (typeof Turbolinks !== 'undefined' && Turbolinks.supported);
}

function turbolinksVisit(params) {
  const path = [window.location.pathname, '?', toQueryString(params)].join('')
  Turbolinks.visit(path);
}

function queryString() {
  return (window.location.search || '').replace(/^\?/, '');
}

function queryStringToParams() {
  const decode = (value) => decodeURIComponent((value || '').replace(/\+/g, '%20'));

  return queryString()
    .split("&")
    .map(pair => pair.split("="))
    .map(([key, value]) => {
      return { name: decode(key), value: decode(value) }
    });
}

function toQueryString(params) {
  const encode = (value) => encodeURIComponent(value || '');

  return params
    .map(({name, value}) => [ encode(name), encode(value) ])
    .map(pair => pair.join('='))
    .join('&')
}

export {
  hasTurbolinks,
  turbolinksVisit,
  queryString,
  queryStringToParams,
  toQueryString
};

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
activeadmin-3.2.5 app/javascript/active_admin/lib/utils.js
activeadmin-3.2.4 app/javascript/active_admin/lib/utils.js
activeadmin-3.2.3 app/javascript/active_admin/lib/utils.js
activeadmin-3.2.2 app/javascript/active_admin/lib/utils.js
activeadmin-3.2.1 app/javascript/active_admin/lib/utils.js
activeadmin-3.2.0 app/javascript/active_admin/lib/utils.js
activeadmin-3.1.0 app/javascript/active_admin/lib/utils.js
activeadmin-3.0.0 app/javascript/active_admin/lib/utils.js
activeadmin-2.14.0 app/javascript/active_admin/lib/utils.js
activeadmin-2.13.1 app/javascript/active_admin/lib/utils.js
activeadmin-2.13.0 app/javascript/active_admin/lib/utils.js
activeadmin-2.12.0 app/javascript/active_admin/lib/utils.js
activeadmin-2.11.2 app/javascript/active_admin/lib/utils.js
activeadmin-2.11.1 app/javascript/active_admin/lib/utils.js
activeadmin-2.11.0 app/javascript/active_admin/lib/utils.js
activeadmin-2.10.1 app/javascript/active_admin/lib/utils.js
activeadmin-2.10.0 app/javascript/active_admin/lib/utils.js
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/app/javascript/active_admin/lib/utils.js
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/app/javascript/active_admin/lib/utils.js
activeadmin-2.9.0 app/javascript/active_admin/lib/utils.js